blob: bfbb85f2f0a63394934f948622d1d255a765ac59 [file] [log] [blame]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +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:
Dennis Dmitriev95126792016-10-18 17:03:30 +03006 - name: root
Dennis Dmitriev6f59add2016-10-18 13:45:27 +03007 sudo: ALL=(ALL) NOPASSWD:ALL
8 shell: /bin/bash
9 ssh_authorized_keys:
10 - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGwjUlYn9UsmWmAGSuEA2sICad7WqxgsJR0HKcMbbxi0tn96h4Cq2iGYmzlJ48egLm5R5pxyWnFvL4b/2zb+kKTPCMwRc9nv7xEGosEFNQEoSDd+gYu2CO0dgS2bX/7m2DXmzvhqPjxWQUXXsb0OYAS1r9Es65FE8y4rLaegz8V35xfH45bTCA0W8VSKh264XtGz12hacqsttE/UvyjJTZe+/XV+xJy3WAWxe8J/MuW1VqbqNewTmpTE/LJU8i6pG4msU6+wH99UvsGAOKQOduynUHKWG3VZg5YCjpbbV/t/pfW/vHB3b3jiifQmNhulyiG/CNnSQ5BahtV/7qPsYt vagrant@cfg01
11
Dennis Dmitriev95126792016-10-18 17:03:30 +030012 disable_root: false
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030013 chpasswd:
14 list: |
Dennis Dmitriev95126792016-10-18 17:03:30 +030015 root:r00tme
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030016 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
Dennis Dmitriev95126792016-10-18 17:03:30 +030021 # Enable root access
Dennis Dmitriev3bf410e2016-10-26 20:22:04 +030022 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
Dennis Dmitriev95126792016-10-18 17:03:30 +030023 - service sshd restart
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030024 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
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030032 # Prepare network connection
33 - sudo ifup {interface_name}
34 - sudo route add default gw {gateway} {interface_name}
35 - sudo ifup eth1
36
37 ############## TCP Cloud cfg01 node ##################
38 - echo "Preparing base OS"
39 - which wget >/dev/null || (apt-get update; apt-get install -y wget)
40
Dennis Dmitriev3bf410e2016-10-26 20:22:04 +030041 - echo "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security extra tcp tcp-salt" > /etc/apt/sources.list
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030042 - wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
43
44 - apt-get clean
45 - apt-get update
46 - apt-get -y upgrade
47
48 # Install common packages
49 - apt-get install -y python-pip
50 - apt-get install -y curl tmux byobu iputils-ping traceroute htop tree
51
52 - echo "Configuring salt master ..."
53 - apt-get install -y salt-master reclass
54 - apt-get install -y salt-formula-*
55
56 - |
57 cat << 'EOF' >> /etc/salt/master.d/master.conf
58 file_roots:
59 base:
60 - /usr/share/salt-formulas/env
61 pillar_opts: False
62 open_mode: True
63 reclass: &reclass
64 storage_type: yaml_fs
65 inventory_base_uri: /srv/salt/reclass
66 ext_pillar:
67 - reclass: *reclass
68 master_tops:
69 reclass: *reclass
70 EOF
71
Dennis Dmitriev45738b92016-10-20 18:11:15 +030072 - echo "Configure git settings and certificate"
73 - touch /root/.git_trusted_certs.pem
74 - for server in git.tcpcloud.eu github.com; do openssl s_client -showcerts -connect $server:443 </dev/null | openssl x509 -outform PEM >> /root/.git_trusted_certs.pem; done
75 - HOME=/root git config --global http.sslCAInfo /root/.git_trusted_certs.pem
76 - HOME=/root git config --global user.email "tcp-qa@example.com"
77 - HOME=/root git config --global user.name "TCP QA"
78
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030079 - echo "Configuring reclass ..."
80 - git clone https://github.com/Mirantis/mk-lab-salt-model.git /srv/salt/reclass -b master
81
82 - mkdir -p /srv/salt/reclass/classes/service
83 - for i in /usr/share/salt-formulas/reclass/service/*; do ln -s $i /srv/salt/reclass/classes/service/; done
84
85 - '[ ! -d /etc/reclass ] && mkdir /etc/reclass'
86 - |
87 cat << 'EOF' >> /etc/reclass/reclass-config.yml
88 storage_type: yaml_fs
89 pretty_print: True
90 output: yaml
91 inventory_base_uri: /srv/salt/reclass
92 EOF
93
94 - echo "Configuring salt minion ..."
95 - apt-get install -y salt-minion
96 - '[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d'
97
98 - |
99 cat << "EOF" >> /etc/salt/minion.d/minion.conf
100 id: {hostname}
101 master: localhost
102 EOF
103
Dennis Dmitriev45738b92016-10-20 18:11:15 +0300104 - echo "Restarting services with workarounds..."
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300105 - service salt-master restart
Dennis Dmitriev3bf410e2016-10-26 20:22:04 +0300106 - sleep 60
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300107 - rm -f /etc/salt/pki/minion/minion_master.pub
108 - service salt-minion restart
109
110 - echo "Showing system info and metadata ..."
Dennis Dmitriev95126792016-10-18 17:03:30 +0300111 - salt-call --no-color grains.items
112 - salt-call --no-color pillar.data
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300113 - reclass -n {hostname}
114
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300115 ########################################################
116 # Node is ready, allow SSH access
117 - echo "Allow SSH access ..."
118 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
119 ########################################################
120
121 write_files:
122 - path: /etc/network/interfaces.d/99-tcp-tests.cfg
123 content: |
124 auto eth0
125 iface eth0 inet dhcp
126
127 # 2nd interface should be UP without IP address
128 auto eth1
Dennis Dmitriev45738b92016-10-20 18:11:15 +0300129 iface eth1 inet dhcp
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300130
Dennis Dmitriev95126792016-10-18 17:03:30 +0300131 - path: /root/.ssh/id_rsa
132 owner: root:root
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300133 permissions: '0600'
134 content: |
135 -----BEGIN RSA PRIVATE KEY-----
136 MIIEpAIBAAKCAQEAxsI1JWJ/VLJlpgBkrhANrCAmne1qsYLCUdBynDG28YtLZ/eo
137 eAqtohmJs5SePHoC5uUeacclpxby+G/9s2/pCkzwjMEXPZ7+8RBqLBBTUBKEg3fo
138 GLtgjtHYEtm1/+5tg15s74aj48VkFF17G9DmAEta/RLOuRRPMuKy2noM/Fd+cXx+
139 OW0wgNFvFUioduuF7Rs9doWnKrLbRP1L8oyU2Xvv11fsSct1gFsXvCfzLltVam6j
140 XsE5qUxPyyVPIuqRuJrFOvsB/fVL7BgDikDnbsp1Bylht1WYOWAo6W21f7f6X1v7
141 xwd2944on0JjYbpcohvwjZ0kOQWobVf+6j7GLQIDAQABAoIBAF0tAAMlmLGY7CQU
142 /R3IctBlRhU1DpZmyTfXc1MbzzqO5Wu44yZbQyjBthcUrdWGEUQy1r4Z2OHq1T54
143 KcPry6DDjuU9Q+rkVXmnC07a3GOmOq7zEEA/3zU01ImJvFNdb8NtCb6ELOKDT7Zo
144 WGUi2h/7M41+OqDzD2m4csYO/3Vvr12sMhn9BfwU4OPpL44A4PJiEryEAw9o5/j/
145 73eyPvgf6tkC4l0mMtfHB9tg/F++iH8fiEr1SMvHGIc9gZNmFYMrs2XfLkAejPfH
146 XrOyw6eqd+kluqw51gHhdeQYwBx6mfOkbhPHWU79FzpH5M1ikdfImZmPCxVf3Ykj
147 nxLoK9UCgYEA4c9agPb/OFyN00nnUMBxzQt1pErpOf/7QhnvNZThomzSV7PyefxF
148 H6G/VlS3gCcrWBCh7mqOSxGcNQwgudVqzUm7QXruQeg4nWcCGSxg7lGYSEf0MyWL
149 5wrd+f9MoV/VV8udIPENjp96o5kwQEVRfsTBNwmk54kup2+br5q8re8CgYEA4VT8
150 UeIN+plP6FjZYITI+SO/ou5goKIhfBrqa5gOXXPc2y6sIu9wBWCr+T7FAF/2gGhS
151 rpVx76zcmx05nwkxIlJh58+G3MVyUDFoWnrtL38vdkBSuOGgNfzcBsFpQvFs8WaW
152 otbuTtkPcXbVdYRr32/C620MxXhUO+svo3CLaaMCgYEA1rjlF8NHl+Gy31rkQg5t
153 aIxgFpVBR+zZkNa2d94V3Ozb65fqmALB/D1Dg6VVROB6P+i5AsyCeHHLd0oMCIof
154 YAyfqrlpvHRE+bAM98ESfyxJwVnipYwrh8z2nZYd2UoWxcCRrtRpjtipts2ha0w/
155 HWudS2e5To5NNdxUT9y1VDMCgYEAxkQiE+ZkyGiXv+hVtLCBqX4EA9fdm9msvudr
156 9qn/kcj9vrntanvlxEWQbCoH61GEsu2YOtdyPiKKpc1sQvwyiHGWhgK7NoxhDiC7
157 IknhYxZ064ajgtu8PWS1MRiDhwypACt1Rej6HNSu2vZl0hZnWF2dU8tLHoHHFEXX
158 T+caNCMCgYBZpD6XBiiEXf0ikXYnXKOmbsyVG80V+yqfLo85qb2RW9TaviOSP43g
159 nB22ReMSHq2cOrs6VTTgfhxefBwzdDFbfKMf6ZU82jCNlpetAZOrhdMHUvcsjSQk
160 XKI6Ldfq6TU3xKujRHfGP+oQ6GLwVCL/kjGxOuSRLFGfRiiqYI3nww==
161 -----END RSA PRIVATE KEY-----
162
Dennis Dmitriev95126792016-10-18 17:03:30 +0300163 - path: /root/.ssh/config
164 owner: root:root
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300165 permissions: '0600'
166 content: |
167 Host *
168 ServerAliveInterval 300
169 ServerAliveCountMax 10
170 StrictHostKeyChecking no
171 UserKnownHostsFile /dev/null