blob: 39297d402521d864b792be3cef953cdbb8a2838b [file] [log] [blame]
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +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
Dmitry Tyzhnenkob610afd2018-02-19 15:43:45 +020022 - cloud-init-per once sudo echo 'sshd:ALL' >> /etc/hosts.deny
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020023 # Enable root access
24 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020025 output:
26 all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
27
28 runcmd:
29 # Mount config drive
30 - mkdir /root/config-drive
31 - mount /dev/sr0 /root/config-drive
32
33 # Create swap
34 - fallocate -l 4G /swapfile
35 - chmod 600 /swapfile
36 - mkswap /swapfile
37 - swapon /swapfile
38 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
39
40 # Run user data script from config drive
Dmitry Tyzhnenko80ce0202019-02-07 13:27:19 +020041 - iptables -I OUTPUT -p tcp --dport 53 -j DROP
42 - iptables -I OUTPUT -p udp --dport 53 -j DROP
Dmitry Tyzhnenkob610afd2018-02-19 15:43:45 +020043 - ifdown --force ens3; ifconfig ens3 down; ip a flush dev ens3; rm -f /var/run/network/ifstate.ens3
44 - ifdown --force ens4; ifconfig ens4 down; ip a flush dev ens4; rm -f /var/run/network/ifstate.ens4
45 - ifdown --force ens5; ifconfig ens5 down; ip a flush dev ens5; rm -f /var/run/network/ifstate.ens5
Dmitry Tyzhnenko80ce0202019-02-07 13:27:19 +020046 - ifdown --force ens6; ifconfig ens6 down; ip a flush dev ens6; rm -f /var/run/network/ifstate.ens6
47 - cd /root/config-drive && cloud-init --file /root/config-drive/vendor-data --debug modules
48 # - [bash, -cex, *master_config]
49 # - cp /root/config-drive/user-data /root/config.sh && chmod 664 /root/config.sh
50 # - sed -i '/^reboot$/d' /root/config.sh
51 # - cd /root && /bin/bash -xe ./config.sh
52
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020053
54 # Enable root access
55 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
Dmitry Tyzhnenko468564a2018-08-23 16:39:06 +030056 - systemctl reload sshd
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020057
58 ########################################################
Dmitry Tyzhnenko468564a2018-08-23 16:39:06 +030059 # Node is ready, allow SSH access and reboot
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020060 - echo "Allow SSH access ..."
Dmitry Tyzhnenkob610afd2018-02-19 15:43:45 +020061 - "sed -i -e '/sshd:ALL/d' /etc/hosts.deny"
62 - touch /is_cloud_init_finish
Dmitry Tyzhnenko468564a2018-08-23 16:39:06 +030063 - reboot
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020064 ########################################################
65
66 write_files:
67 - path: /root/.ssh/config
68 owner: root:root
69 permissions: '0600'
70 content: |
71 Host *
72 ServerAliveInterval 300
73 ServerAliveCountMax 10
74 StrictHostKeyChecking no
75 UserKnownHostsFile /dev/null
Dmitry Tyzhnenkob610afd2018-02-19 15:43:45 +020076
77 ssh_pwauth: True
Dmitry Tyzhnenko80ce0202019-02-07 13:27:19 +020078 disable_root: false
Dmitry Tyzhnenkob610afd2018-02-19 15:43:45 +020079 users:
80 - name: root
81 sudo: ALL=(ALL) NOPASSWD:ALL
82 shell: /bin/bash
83 ssh_authorized_keys:
84 {% for key in config.underlay.ssh_keys %}
85 - ssh-rsa {{ key['public'] }}
86 {% endfor %}
Dmitry Tyzhnenko80ce0202019-02-07 13:27:19 +020087
88 chpasswd:
89 list: |
90 root:r00tme
91 expire: False