blob: b8502838ebba0b9eeb3cf33726fa5d37bac657a7 [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 Tyzhnenkob610afd2018-02-19 15:43:45 +020041 - ifdown --force ens3; ifconfig ens3 down; ip a flush dev ens3; rm -f /var/run/network/ifstate.ens3
42 - ifdown --force ens4; ifconfig ens4 down; ip a flush dev ens4; rm -f /var/run/network/ifstate.ens4
43 - ifdown --force ens5; ifconfig ens5 down; ip a flush dev ens5; rm -f /var/run/network/ifstate.ens5
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020044 - cd /root/config-drive && /bin/bash -xe ./user-data
45
46 # Enable root access
47 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
48
49 ########################################################
50 # Node is ready, allow SSH access
51 - echo "Allow SSH access ..."
Dmitry Tyzhnenkob610afd2018-02-19 15:43:45 +020052 - "sed -i -e '/sshd:ALL/d' /etc/hosts.deny"
53 - touch /is_cloud_init_finish
Dmitry Tyzhnenko5a5d8da2017-12-14 14:14:42 +020054 ########################################################
55
56 write_files:
57 - path: /root/.ssh/config
58 owner: root:root
59 permissions: '0600'
60 content: |
61 Host *
62 ServerAliveInterval 300
63 ServerAliveCountMax 10
64 StrictHostKeyChecking no
65 UserKnownHostsFile /dev/null
Dmitry Tyzhnenkob610afd2018-02-19 15:43:45 +020066
67 ssh_pwauth: True
68 users:
69 - name: root
70 sudo: ALL=(ALL) NOPASSWD:ALL
71 shell: /bin/bash
72 ssh_authorized_keys:
73 {% for key in config.underlay.ssh_keys %}
74 - ssh-rsa {{ key['public'] }}
75 {% endfor %}