Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 1 | | # 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: |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 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 | # Prepare network connection |
| 29 | - sudo ifdown ens3 |
| 30 | - sudo ip r d default || true # remove existing default route to get it from dhcp |
| 31 | - sudo ifup ens3 |
| 32 | |
| 33 | #- sudo route add default gw {gateway} {interface_name} |
| 34 | - rm /etc/resolv.conf |
| 35 | - touch /etc/resolv.conf |
| 36 | - LOCAL_IP=$(ifconfig ens3 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1 | cut -d"." -f1-3) |
| 37 | - export DNS_IP=$LOCAL_IP".122" |
| 38 | - echo "nameserver $DNS_IP" >> /etc/resolv.conf; |
| 39 | - echo "nameserver $LOCAL_IP.1" >> /etc/resolv.conf; |
| 40 | - echo "supersede domain-name-servers $DNS_IP" >> /etc/dhcp/dhclient.conf |
| 41 | |
| 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 | |
Dennis Dmitriev | 5f71f9e | 2018-10-19 13:02:43 +0300 | [diff] [blame^] | 49 | - mkdir -p /srv/salt/reclass/nodes |
| 50 | - systemctl enable salt-master |
| 51 | - systemctl enable salt-minion |
| 52 | - systemctl start salt-master |
| 53 | - systemctl start salt-minion |
| 54 | - salt-call -l info --timeout=120 test.ping |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 55 | |
| 56 | write_files: |
| 57 | - path: /etc/network/interfaces |
| 58 | content: | |
| 59 | auto ens3 |
| 60 | iface ens3 inet dhcp |
| 61 | |
| 62 | - path: /root/.ssh/config |
| 63 | owner: root:root |
| 64 | permissions: '0600' |
| 65 | content: | |
| 66 | Host * |
| 67 | ServerAliveInterval 300 |
| 68 | ServerAliveCountMax 10 |
| 69 | StrictHostKeyChecking no |
| 70 | UserKnownHostsFile /dev/null |