blob: 4f140a0ebedeab7a9f2ff201b3c157bc1ada24a0 [file] [log] [blame]
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +03001| # 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:
Artem Panchenkodb0a97f2017-06-27 19:09:13 +030010 {% for key in config.underlay.ssh_keys %}
11 - ssh-rsa {{ key['public'] }}
12 {% endfor %}
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030013
14 disable_root: false
15 chpasswd:
16 list: |
17 root:r00tme
18 expire: False
19
20 bootcmd:
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030021 # Enable root access
22 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
23 - service sshd restart
24 output:
25 all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
26
27 runcmd:
28 # Configure dhclient
29 - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
30 - sudo resolvconf -u
31
32 # Prepare network connection
Dennis Dmitrievf00a3842018-01-24 16:44:26 +020033 - sudo ifdown ens3
Dennis Dmitriev002b8432018-01-25 03:26:14 +020034 - sudo ip r d default || true # remove existing default route to get it from dhcp
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030035 - sudo ifup ens3
36 #- sudo route add default gw {gateway} {interface_name}
Dennis Dmitriev002b8432018-01-25 03:26:14 +020037 - sudo ifdown ens4
38 - sudo ifdown ens5
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030039 - sudo ifup ens4
Sergii Golovatiuk5b659d42017-05-26 17:38:06 +020040 - sudo ifup ens5
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030041
42 # Create swap
43 - fallocate -l 4G /swapfile
44 - chmod 600 /swapfile
45 - mkswap /swapfile
46 - swapon /swapfile
47 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
48
Sergii Golovatiuk17ef1492017-05-29 19:54:03 +020049 - echo "nameserver 172.18.208.44" >> /etc/resolv.conf;
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030050
51 write_files:
52 - path: /etc/network/interfaces
53 content: |
54 auto ens3
55 iface ens3 inet dhcp
56 auto ens4
57 iface ens4 inet dhcp
Sergii Golovatiuk5b659d42017-05-26 17:38:06 +020058 auto ens5
59 iface ens5 inet dhcp
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030060
Tatyana Leontovichbb6d1a72017-05-17 14:10:38 +030061 - path: /root/.ssh/config
62 owner: root:root
63 permissions: '0600'
64 content: |
65 Host *
66 ServerAliveInterval 300
67 ServerAliveCountMax 10
68 StrictHostKeyChecking no
69 UserKnownHostsFile /dev/null