blob: 891fdb0a84b183ff1b05ef3f9962fa39f97e7b64 [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:
6 - name: vagrant
7 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
12 chpasswd:
13 list: |
14 vagrant:vagrant
15 expire: False
16
17 bootcmd:
18 # Block access to SSH while node is preparing
19 - cloud-init-per once sudo iptables -A INPUT -p tcp --dport 22 -j DROP
20 output:
21 all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
22
23 runcmd:
24 # Configure dhclient
25 - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
26 - sudo resolvconf -u
27
28 # Change owner for .ssh/
29 - chown -R vagrant:vagrant /home/vagrant/.ssh
30
31 # Prepare network connection
32 - sudo ifup {interface_name}
33 - sudo route add default gw {gateway} {interface_name}
34 - sudo ifup eth1
35
36 ############## TCP Cloud cfg01 node ##################
37 - echo "Preparing base OS"
38 - which wget >/dev/null || (apt-get update; apt-get install -y wget)
39
40 - echo "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp tcp-salt" > /etc/apt/sources.list
41 - wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
42
43 - apt-get clean
44 - apt-get update
45 - apt-get -y upgrade
46
47 # Install common packages
48 - apt-get install -y python-pip
49 - apt-get install -y curl tmux byobu iputils-ping traceroute htop tree
50
51 - echo "Configuring salt master ..."
52 - apt-get install -y salt-master reclass
53 - apt-get install -y salt-formula-*
54
55 - |
56 cat << 'EOF' >> /etc/salt/master.d/master.conf
57 file_roots:
58 base:
59 - /usr/share/salt-formulas/env
60 pillar_opts: False
61 open_mode: True
62 reclass: &reclass
63 storage_type: yaml_fs
64 inventory_base_uri: /srv/salt/reclass
65 ext_pillar:
66 - reclass: *reclass
67 master_tops:
68 reclass: *reclass
69 EOF
70
71 - echo "Configuring reclass ..."
72 - git clone https://github.com/Mirantis/mk-lab-salt-model.git /srv/salt/reclass -b master
73
74 - mkdir -p /srv/salt/reclass/classes/service
75 - for i in /usr/share/salt-formulas/reclass/service/*; do ln -s $i /srv/salt/reclass/classes/service/; done
76
77 - '[ ! -d /etc/reclass ] && mkdir /etc/reclass'
78 - |
79 cat << 'EOF' >> /etc/reclass/reclass-config.yml
80 storage_type: yaml_fs
81 pretty_print: True
82 output: yaml
83 inventory_base_uri: /srv/salt/reclass
84 EOF
85
86 - echo "Configuring salt minion ..."
87 - apt-get install -y salt-minion
88 - '[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d'
89
90 - |
91 cat << "EOF" >> /etc/salt/minion.d/minion.conf
92 id: {hostname}
93 master: localhost
94 EOF
95
96 - echo "Restarting services ..."
97 - service salt-master restart
98 - rm -f /etc/salt/pki/minion/minion_master.pub
99 - service salt-minion restart
100
101 - echo "Showing system info and metadata ..."
102 #- salt-call --no-color grains.items
103 #- salt-call --no-color pillar.data
104 - reclass -n {hostname}
105
106 #- echo "Running complete state ..."
107 #- salt-call --no-color state.sls linux openssh salt.minion
108 #- salt-call --no-color state.sls salt.master
109 #- service salt-minion restart
110 #salt-call --no-color state.highstate
111
112 ########################################################
113 # Node is ready, allow SSH access
114 - echo "Allow SSH access ..."
115 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
116 ########################################################
117
118 write_files:
119 - path: /etc/network/interfaces.d/99-tcp-tests.cfg
120 content: |
121 auto eth0
122 iface eth0 inet dhcp
123
124 # 2nd interface should be UP without IP address
125 auto eth1
126 iface eth1 inet manual
127 pre-up ifconfig $IFACE up
128 post-down ifconfig $IFACE down
129
130 - path: /home/vagrant/.ssh/id_rsa
131 owner: vagrant:vagrant
132 permissions: '0600'
133 content: |
134 -----BEGIN RSA PRIVATE KEY-----
135 MIIEpAIBAAKCAQEAxsI1JWJ/VLJlpgBkrhANrCAmne1qsYLCUdBynDG28YtLZ/eo
136 eAqtohmJs5SePHoC5uUeacclpxby+G/9s2/pCkzwjMEXPZ7+8RBqLBBTUBKEg3fo
137 GLtgjtHYEtm1/+5tg15s74aj48VkFF17G9DmAEta/RLOuRRPMuKy2noM/Fd+cXx+
138 OW0wgNFvFUioduuF7Rs9doWnKrLbRP1L8oyU2Xvv11fsSct1gFsXvCfzLltVam6j
139 XsE5qUxPyyVPIuqRuJrFOvsB/fVL7BgDikDnbsp1Bylht1WYOWAo6W21f7f6X1v7
140 xwd2944on0JjYbpcohvwjZ0kOQWobVf+6j7GLQIDAQABAoIBAF0tAAMlmLGY7CQU
141 /R3IctBlRhU1DpZmyTfXc1MbzzqO5Wu44yZbQyjBthcUrdWGEUQy1r4Z2OHq1T54
142 KcPry6DDjuU9Q+rkVXmnC07a3GOmOq7zEEA/3zU01ImJvFNdb8NtCb6ELOKDT7Zo
143 WGUi2h/7M41+OqDzD2m4csYO/3Vvr12sMhn9BfwU4OPpL44A4PJiEryEAw9o5/j/
144 73eyPvgf6tkC4l0mMtfHB9tg/F++iH8fiEr1SMvHGIc9gZNmFYMrs2XfLkAejPfH
145 XrOyw6eqd+kluqw51gHhdeQYwBx6mfOkbhPHWU79FzpH5M1ikdfImZmPCxVf3Ykj
146 nxLoK9UCgYEA4c9agPb/OFyN00nnUMBxzQt1pErpOf/7QhnvNZThomzSV7PyefxF
147 H6G/VlS3gCcrWBCh7mqOSxGcNQwgudVqzUm7QXruQeg4nWcCGSxg7lGYSEf0MyWL
148 5wrd+f9MoV/VV8udIPENjp96o5kwQEVRfsTBNwmk54kup2+br5q8re8CgYEA4VT8
149 UeIN+plP6FjZYITI+SO/ou5goKIhfBrqa5gOXXPc2y6sIu9wBWCr+T7FAF/2gGhS
150 rpVx76zcmx05nwkxIlJh58+G3MVyUDFoWnrtL38vdkBSuOGgNfzcBsFpQvFs8WaW
151 otbuTtkPcXbVdYRr32/C620MxXhUO+svo3CLaaMCgYEA1rjlF8NHl+Gy31rkQg5t
152 aIxgFpVBR+zZkNa2d94V3Ozb65fqmALB/D1Dg6VVROB6P+i5AsyCeHHLd0oMCIof
153 YAyfqrlpvHRE+bAM98ESfyxJwVnipYwrh8z2nZYd2UoWxcCRrtRpjtipts2ha0w/
154 HWudS2e5To5NNdxUT9y1VDMCgYEAxkQiE+ZkyGiXv+hVtLCBqX4EA9fdm9msvudr
155 9qn/kcj9vrntanvlxEWQbCoH61GEsu2YOtdyPiKKpc1sQvwyiHGWhgK7NoxhDiC7
156 IknhYxZ064ajgtu8PWS1MRiDhwypACt1Rej6HNSu2vZl0hZnWF2dU8tLHoHHFEXX
157 T+caNCMCgYBZpD6XBiiEXf0ikXYnXKOmbsyVG80V+yqfLo85qb2RW9TaviOSP43g
158 nB22ReMSHq2cOrs6VTTgfhxefBwzdDFbfKMf6ZU82jCNlpetAZOrhdMHUvcsjSQk
159 XKI6Ldfq6TU3xKujRHfGP+oQ6GLwVCL/kjGxOuSRLFGfRiiqYI3nww==
160 -----END RSA PRIVATE KEY-----
161
162 - path: /home/vagrant/.ssh/config
163 owner: vagrant:vagrant
164 permissions: '0600'
165 content: |
166 Host *
167 ServerAliveInterval 300
168 ServerAliveCountMax 10
169 StrictHostKeyChecking no
170 UserKnownHostsFile /dev/null