blob: c87114664293371cd13efb06c345926de2edf9c2 [file] [log] [blame]
Dennis Dmitriev85559962018-01-30 15:35:51 +02001| # 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 {% for key in config.underlay.ssh_keys %}
11 - ssh-rsa {{ key['public'] }}
12 {% endfor %}
13
14 disable_root: false
15 chpasswd:
16 list: |
17 root:r00tme
18 expire: False
19
20 bootcmd:
21 # Block access to SSH while node is preparing
22 - cloud-init-per once sudo iptables -A INPUT -p tcp --dport 22 -j DROP
23 # Enable root access
24 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
25 - service sshd restart
26 output:
27 all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
28
29 runcmd:
30 # Prepare network connection
31 - sudo ifdown ens3
32 - sudo ifup ens3
33 #- sudo route add default gw {gateway} {interface_name}
34
35 # Configure dhclient
36 - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
37 - sudo resolvconf -u
38
39 # Enable grub menu using updated config below
40 - update-grub
41
42 # Create swap
43 #- fallocate -l 16G /swapfile
44 #- chmod 600 /swapfile
45 #- mkswap /swapfile
46 #- swapon /swapfile
47 #- echo "/swapfile none swap defaults 0 0" >> /etc/fstab
48
49 ############## TCP Cloud cfg01 node ##################
50 - echo "Preparing base OS"
51
52 - echo "nameserver 172.18.208.44" >> /etc/resolv.conf;
53 - echo "nameserver 8.8.8.8" >> /etc/resolv.conf;
54
55 - apt-get clean
56 - apt-get update
57
58 # Ensure that the salt-master service is ready to receive requests
59 - salt-key -y -D
60 - service salt-master restart
61 - service salt-minion restart
Dennis Dmitriev1d3472e2018-02-16 22:04:19 +020062 - apt-get install -y salt-formula-*
Dennis Dmitrievadef0952018-02-17 17:17:02 +020063 - for f in $(ls -1 /usr/share/salt-formulas/reclass/service); do ln -s /usr/share/salt-formulas/reclass/service/$f /srv/salt/reclass/classes/service/ || true; done
Dennis Dmitriev85559962018-01-30 15:35:51 +020064 - salt-call --timeout=180 test.ping
65
66 ########################################################
67 # Node is ready, allow SSH access
68 - echo "Allow SSH access ..."
69 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
70 ########################################################
71
72 write_files:
73 - path: /etc/default/grub.d/97-enable-grub-menu.cfg
74 content: |
75 GRUB_RECORDFAIL_TIMEOUT=30
76 GRUB_TIMEOUT=3
77 GRUB_TIMEOUT_STYLE=menu
78
79 - path: /etc/network/interfaces
80 content: |
81 auto ens3
82 iface ens3 inet dhcp
83
84 - path: /root/.ssh/config
85 owner: root:root
86 permissions: '0600'
87 content: |
88 Host *
89 ServerAliveInterval 300
90 ServerAliveCountMax 10
91 StrictHostKeyChecking no
92 UserKnownHostsFile /dev/null
93
94 # Fix hardcoded IP address in the minion.conf
95 - path: /etc/salt/minion.d/minion.conf
96 content: |
97 master: 127.0.0.1
98 id: cfg01.{{ DOMAIN_NAME }}