blob: d07e03f774d4ca4191348b4de0e7959934f7e5cf [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;
Dennis Dmitriev85559962018-01-30 15:35:51 +020053
54 - apt-get clean
55 - apt-get update
56
57 # Ensure that the salt-master service is ready to receive requests
58 - salt-key -y -D
59 - service salt-master restart
60 - service salt-minion restart
Dennis Dmitriev1d3472e2018-02-16 22:04:19 +020061 - apt-get install -y salt-formula-*
Dennis Dmitrievadef0952018-02-17 17:17:02 +020062 - 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 +020063 - salt-call --timeout=180 test.ping
64
65 ########################################################
66 # Node is ready, allow SSH access
67 - echo "Allow SSH access ..."
68 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
69 ########################################################
70
71 write_files:
72 - path: /etc/default/grub.d/97-enable-grub-menu.cfg
73 content: |
74 GRUB_RECORDFAIL_TIMEOUT=30
75 GRUB_TIMEOUT=3
76 GRUB_TIMEOUT_STYLE=menu
77
78 - path: /etc/network/interfaces
79 content: |
80 auto ens3
81 iface ens3 inet dhcp
82
83 - path: /root/.ssh/config
84 owner: root:root
85 permissions: '0600'
86 content: |
87 Host *
88 ServerAliveInterval 300
89 ServerAliveCountMax 10
90 StrictHostKeyChecking no
91 UserKnownHostsFile /dev/null
92
93 # Fix hardcoded IP address in the minion.conf
94 - path: /etc/salt/minion.d/minion.conf
95 content: |
96 master: 127.0.0.1
97 id: cfg01.{{ DOMAIN_NAME }}