blob: be74a8875a3b8fac65e0685bc4fce3fc57139afc [file] [log] [blame]
Dmitry Tyzhnenko35413c02018-03-05 14:12:37 +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 # Enable root access
22 - sudo ifdown ens3
23 - rm /etc/network/interfaces
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 # Configure dhclient
31 - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
32 - sudo resolvconf -u
33
34 # Prepare network connection
35 - sudo ifdown ens3 || true
36 - sudo ip r d default || true # remove existing default route to get it from dhcp
37 - sudo ifup ens3
38 #- sudo route add default gw {gateway} {interface_name}
39
40 # Create swap
41 - fallocate -l 4G /swapfile
42 - chmod 600 /swapfile
43 - mkswap /swapfile
44 - swapon /swapfile
45 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
46
47 - echo "nameserver 172.18.176.6" >> /etc/resolv.conf;
48
49 write_files:
50 - path: /etc/network/interfaces
51 content: |
52 auto ens3
53 iface ens3 inet static
54 address {address}
55 netmask {netmask}
56 gateway {gateway}
57 dns-nameservers 172.18.176.6
58
59 - path: /root/.ssh/config
60 owner: root:root
61 permissions: '0600'
62 content: |
63 Host *
64 ServerAliveInterval 300
65 ServerAliveCountMax 10
66 StrictHostKeyChecking no
67 UserKnownHostsFile /dev/null