blob: f35127dc6a21f415bee18b00811f3831ae9f9bc8 [file] [log] [blame]
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +03001| # All the data below will be stored as a string object
2 #cloud-config, see http://cloudinit.readthedocs.io/en/latest/topics/examples.html
3
4 ssh_pwauth: True
5 users:
6 - name: root
7 sudo: ALL=(ALL) NOPASSWD:ALL
8 shell: /bin/bash
9 ssh_authorized_keys:
10 - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCp0evjOaK8c8SKYK4r2+0BN7g+8YSvQ2n8nFgOURCyvkJqOHi1qPGZmuN0CclYVdVuZiXbWw3VxRbSW3EH736VzgY1U0JmoTiSamzLHaWsXvEIW8VCi7boli539QJP0ikJiBaNAgZILyCrVPN+A6mfqtacs1KXdZ0zlMq1BPtFciR1JTCRcVs5vP2Wwz5QtY2jMIh3aiwkePjMTQPcfmh1TkOlxYu5IbQyZ3G1ahA0mNKI9a0dtF282av/F6pwB/N1R1nEZ/9VtcN2I1mf1NW/tTHEEcTzXYo1R/8K9vlqAN8QvvGLZtZduGviNVNoNWvoxaXxDt8CPv2B2NCdQFZp
11
12 disable_root: false
13 chpasswd:
14 list: |
15 root:r00tme
16 expire: False
17
18 bootcmd:
19 # Block access to SSH while node is preparing
20 - cloud-init-per once sudo iptables -A INPUT -p tcp --dport 22 -j DROP
21 # Enable root access
22 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
23 - service sshd restart
24 output:
25 all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
26
27 runcmd:
28 # Configure dhclient
29 - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
30 - sudo resolvconf -u
31
32 # Prepare network connection
33 - sudo ifup ens3
34 #- sudo route add default gw {gateway} {interface_name}
35 - sudo ifup ens4
36
37 # Create swap
38 - fallocate -l 4G /swapfile
39 - chmod 600 /swapfile
40 - mkswap /swapfile
41 - swapon /swapfile
42 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
43
44 ############## TCP Cloud cfg01 node ##################
45 #- sleep 120
46 - echo "Preparing base OS"
47
48 - echo "172.18.248.114 jenkins.mcp.mirantis.net gerrit.mcp.mirantis.net" >> /etc/hosts;
49 - echo "185.135.196.10 apt-mk.mirantis.com" >> /etc/hosts;
Dennis Dmitriev80fe32d2017-06-02 13:47:35 +030050 - echo "nameserver 172.18.208.44" >> /etc/resolv.conf;
51 - echo "nameserver 8.8.8.8" >> /etc/resolv.conf;
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +030052 - which wget >/dev/null || (apt-get update; apt-get install -y wget);
Dennis Dmitriev620e26d2017-05-25 18:28:44 +030053 - apt-get install -y ntp
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +030054
55 - export IRONIC_PXE_MANAGER=dnsmasq
56 - export IRONIC_PXE_INTERFACE_NAME=ens4
Dennis Dmitrievcacce7d2017-05-26 22:28:22 +030057 - export IRONIC_PXE_INTERFACE_ADDRESS={{ os_env('IRONIC_PXE_INTERFACE_ADDRESS', '10.0.175.2') }}
Dennis Dmitriev6dd3db72017-05-26 22:32:18 +030058 - export IRONIC_DHCP_POOL_NETMASK={{ os_env('IRONIC_DHCP_POOL_NETMASK', '255.255.255.0') }}
59 - export IRONIC_DHCP_POOL_NETMASK_PREFIX={{ os_env('IRONIC_DHCP_POOL_NETMASK_PREFIX', '24') }}
Dennis Dmitrievcacce7d2017-05-26 22:28:22 +030060 - export IRONIC_DHCP_POOL_START={{ os_env('IRONIC_DHCP_POOL_START', '10.0.175.100') }}
61 - export IRONIC_DHCP_POOL_END={{ os_env('IRONIC_DHCP_POOL_END', '10.0.175.200') }}
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +030062 - export DNSMASQ_USE_EXTERNAL_DNS=true
63 - ip a a $IRONIC_PXE_INTERFACE_ADDRESS/$IRONIC_DHCP_POOL_NETMASK_PREFIX dev $IRONIC_PXE_INTERFACE_NAME
64 - curl https://raw.githubusercontent.com/dis-xcom/underpillar/master/bootstrap.sh -o ./bootstrap.sh && bash ./bootstrap.sh
65
Dennis Dmitriev80fe32d2017-06-02 13:47:35 +030066 # Disable dnsmasq in favour to external DHCP provider
67 #- systemctl disable dnsmasq
68 # - service dnsmasq stop
69
70 {%- if os_env('IRONIC_DNSMASQ_HOSTFILE', '') %}
71 - echo "dhcp-hostsfile=/var/lib/libvirt/dnsmasq/{{ IRONIC_ENV_NAME }}.hostsfile" >> /etc/dnsmasq.conf
72 - service dnsmasq restart
73 {%- endif %}
74
75 # Enable SNAT to allow internet access for deploying nodes using ironic node as a gateway
76 - iptables -t nat -A POSTROUTING -s {{ os_env('IRONIC_DHCP_POOL_START', '10.0.175.100') }}/{{ os_env('IRONIC_DHCP_POOL_NETMASK_PREFIX', '24') }} ! -d {{ os_env('IRONIC_DHCP_POOL_START', '10.0.175.100') }}/{{ os_env('IRONIC_DHCP_POOL_NETMASK_PREFIX', '24') }} -j MASQUERADE
77
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +030078 - echo "Building ironic agent image (stable/newton) ..."
79 - apt-get install -y docker.io gzip uuid-runtime cpio findutils grep gnupg make
80 - service docker start
81 - git clone https://git.openstack.org/openstack/ironic-python-agent /tmp/ironic-python-agent
82 - cd /tmp/ironic-python-agent/imagebuild/coreos; git checkout stable/newton; make
83 - cp /tmp/ironic-python-agent/imagebuild/coreos/UPLOAD/coreos_production_pxe_image-oem.cpio.gz /httpboot/
84 - cp /tmp/ironic-python-agent/imagebuild/coreos/UPLOAD/coreos_production_pxe.vmlinuz /httpboot/
85 - chmod a+r /httpboot/coreos_production_pxe*
86
87 - echo "Download ubuntu cloudinit image"
88 - wget https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img -O /httpboot/xenial-server-cloudimg-amd64.qcow2
89
90 ########################################################
91 # Node is ready, allow SSH access
92 - echo "Allow SSH access ..."
93 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
94 ########################################################
95
96 write_files:
97 - path: /etc/network/interfaces
98 content: |
99 auto ens3
100 iface ens3 inet dhcp
101 auto ens4
102 iface ens4 inet manual
103
104 - path: /root/.ssh/id_rsa
105 owner: root:root
106 permissions: '0600'
107 content: |
108 -----BEGIN RSA PRIVATE KEY-----
109 MIIEogIBAAKCAQEAqdHr4zmivHPEimCuK9vtATe4PvGEr0Np/JxYDlEQsr5Cajh4
110 tajxmZrjdAnJWFXVbmYl21sN1cUW0ltxB+9+lc4GNVNCZqE4kmpsyx2lrF7xCFvF
111 Qou26JYud/UCT9IpCYgWjQIGSC8gq1TzfgOpn6rWnLNSl3WdM5TKtQT7RXIkdSUw
112 kXFbObz9lsM+ULWNozCId2osJHj4zE0D3H5odU5DpcWLuSG0MmdxtWoQNJjSiPWt
113 HbRdvNmr/xeqcAfzdUdZxGf/VbXDdiNZn9TVv7UxxBHE812KNUf/Cvb5agDfEL7x
114 i2bWXbhr4jVTaDVr6MWl8Q7fAj79gdjQnUBWaQIDAQABAoIBAFU3kU6yIna9BViH
115 UX+S2ijtRBjZ68JjavEnp4xvo5h+nydcdT57q9lv/0nAi3g3gmXm/oJH+/ZU87HV
116 zy+zP+t+umDSChUkPBZFL5jxpKyN7BhMrP1KzRuEGYd6vJE/nfY5g095P5vDgnpX
117 o+SNg/YqrY1u8zgr/hnfRaV2/XyIDEEcQXTHseWTnnMQnULFU88xL8yq8ACT5GhK
118 7A9m5ukfcU6d/fs/psz5Yqw5IQsWbv1yJ3/FKufPHlo2Nzh3/3eDAZUXvaBgf1so
119 FWFpHtkry3OXOGaZ98HgF9hL0twS0pzMvuypdGUQAt6nyB1N5re4LK/MAOddqwEc
120 1+NQzfECgYEA2ryEf0GLJdtiYs3F4HbwTwJVIXdyWv7kjYGeMkutzzAjXl6wx8aq
121 kfqLJ7x7UkR5unZ1ajEbKBciAlSuFA+Gikn6a4Lv8h87aSnHpPd/2VSitRlI/gW7
122 w4U4CL3Br1JyonU5WA7VYfTow7KnHBhdwm27RMA9uosyIpveQRpqSG0CgYEAxsAS
123 wCQKrhuPq2YtGtFR7K4BL+N+0E1Vq6h49u1ukcgUe0GHVD3VzBypNCv7rWEVHzAg
124 biCVi7PCjzZYW4fYZmzVD4JbFLVGOUu7aJwLaE4wDe72DNr6YZhcS+Ta98BP+x0q
125 Wt34JNPDabRPfhXfhiCqnWjjod+4Zqx4VJVNgG0CgYB5EXL8xJhyAbW5Hk/x56Mm
126 +BGKjoR7HS3/rMiU6hJv5SMObrbGPI3YcqZm/gn8BO6jaEGg30E6tWMbiyc270j2
127 be/vZe/NQcAuevOHuX3IGvJb7nzaLO46UBgtrmnv0mCkzuFIfh1ZNKdI+i9Ie6wZ
128 m4bVjNod0EGVqlQgELDXGQKBgB+NNmzSS++/6FrpaZesSzkrlnynvOYMoOETacCp
129 iLgT70xx5q308w/oLORfZyDrHJNK7JsPCS6YZvadRgGh2zTHajuAEj2DWZaW8zV0
130 MEtqvi44FU+NI9qCeYSC3FAgc5IF20d5nX8bLxaEzWnSxx1f6jX7BMgZ4AhMsP2c
131 hiUxAoGAFaxn+t9blIjqUiuh0smSYFhLBVPZveYHQDmQYERjktptBd3X95fGnSKh
132 iDe2iPGyud2+Yu4X/VjHLh/MRru+ZXvPXw1XwEqX93q8a1n283ul0Rl9+KKKOVHR
133 eecTjI/BfXBf33mPRKny3xuHw6uwta2T3OXky9IhqYS1kkHiZWA=
134 -----END RSA PRIVATE KEY-----
135
136 - path: /root/.ssh/config
137 owner: root:root
138 permissions: '0600'
139 content: |
140 Host *
141 ServerAliveInterval 300
142 ServerAliveCountMax 10
143 StrictHostKeyChecking no
144 UserKnownHostsFile /dev/null
Dennis Dmitriev80fe32d2017-06-02 13:47:35 +0300145
146 {%- if os_env('IRONIC_DNSMASQ_HOSTFILE', '') %}
147 - path: /var/lib/libvirt/dnsmasq/{{ IRONIC_ENV_NAME }}.hostsfile
148 permissions: '0644'
149 content: |
150 {%- for host in os_env('IRONIC_DNSMASQ_HOSTFILE').splitlines() %}
151 {{ host }}
152 {%- endfor %}
153 {%- endif %}