blob: 1e318a5a5843925cb4626141ce204e7753bd1a6c [file] [log] [blame]
sgudzf5a51222018-05-11 14:20:50 +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:
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 - 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
33 - sudo ifdown ens3
34 - sudo ip r d default || true # remove existing default route to get it from dhcp
35 - sudo ifup ens3
36 - sudo route add default gw {gateway} ens3
37
38 # Create swap
39 - fallocate -l 4G /swapfile
40 - chmod 600 /swapfile
41 - mkswap /swapfile
42 - swapon /swapfile
43 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
44
45 - echo "nameserver 172.18.208.44" > /etc/resolv.conf;
46
47 - export MAAS_PXE_INTERFACE_NAME=ens4
48 - export MAAS_PXE_INTERFACE_ADDRESS={{ os_env('MAAS_PXE_INTERFACE_ADDRESS', '172.16.49.66') }}
49 - export MAAS_DHCP_POOL_NETMASK={{ os_env('MAAS_DHCP_POOL_NETMASK', '255.255.255.192') }}
50 - export MAAS_DHCP_POOL_NETMASK_PREFIX={{ os_env('MAAS_DHCP_POOL_NETMASK_PREFIX', '26') }}
51 - export MAAS_DHCP_POOL_START={{ os_env('MAAS_DHCP_POOL_START', '172.16.49.77') }}
52 - export MAAS_DHCP_POOL_END={{ os_env('MAAS_DHCP_POOL_END', '172.16.49.119') }}
53 - ifconfig $MAAS_PXE_INTERFACE_NAME $MAAS_PXE_INTERFACE_ADDRESS/$MAAS_DHCP_POOL_NETMASK_PREFIX
54
55 write_files:
56 - path: /etc/network/interfaces
57 content: |
58 auto ens3
59 iface ens3 inet dhcp
60
61 - 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