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