blob: 83a89004f1bf9d8992216bb82afaaa67d74e2cfc [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-*
63 - rm -rf /srv/salt/reclass/classes/service
64 - ln -s /usr/share/salt-formulas/reclass/service /srv/salt/reclass/classes/service
Dennis Dmitriev85559962018-01-30 15:35:51 +020065 - salt-call --timeout=180 test.ping
66
67 ########################################################
68 # Node is ready, allow SSH access
69 - echo "Allow SSH access ..."
70 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
71 ########################################################
72
73 write_files:
74 - path: /etc/default/grub.d/97-enable-grub-menu.cfg
75 content: |
76 GRUB_RECORDFAIL_TIMEOUT=30
77 GRUB_TIMEOUT=3
78 GRUB_TIMEOUT_STYLE=menu
79
80 - path: /etc/network/interfaces
81 content: |
82 auto ens3
83 iface ens3 inet dhcp
84
85 - path: /root/.ssh/config
86 owner: root:root
87 permissions: '0600'
88 content: |
89 Host *
90 ServerAliveInterval 300
91 ServerAliveCountMax 10
92 StrictHostKeyChecking no
93 UserKnownHostsFile /dev/null
94
95 # Fix hardcoded IP address in the minion.conf
96 - path: /etc/salt/minion.d/minion.conf
97 content: |
98 master: 127.0.0.1
99 id: cfg01.{{ DOMAIN_NAME }}