Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +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: |
Artem Panchenko | db0a97f | 2017-06-27 19:09:13 +0300 | [diff] [blame] | 10 | {% for key in config.underlay.ssh_keys %} |
| 11 | - ssh-rsa {{ key['public'] }} |
| 12 | {% endfor %} |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 13 | |
| 14 | disable_root: false |
| 15 | chpasswd: |
| 16 | list: | |
| 17 | root:r00tme |
| 18 | expire: False |
| 19 | |
| 20 | bootcmd: |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +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 | # Configure dhclient |
| 29 | - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base |
| 30 | - sudo resolvconf -u |
| 31 | |
| 32 | # Prepare network connection |
Dennis Dmitriev | f00a384 | 2018-01-24 16:44:26 +0200 | [diff] [blame] | 33 | - sudo ifdown ens3 |
Dennis Dmitriev | 002b843 | 2018-01-25 03:26:14 +0200 | [diff] [blame] | 34 | - sudo ip r d default || true # remove existing default route to get it from dhcp |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 35 | - sudo ifup ens3 |
| 36 | #- sudo route add default gw {gateway} {interface_name} |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 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 | |
Dennis Dmitriev | 7486186 | 2017-09-28 17:02:13 +0300 | [diff] [blame] | 45 | - echo "nameserver 172.18.208.44" >> /etc/resolv.conf; |
Dennis Dmitriev | b4b5c10 | 2017-05-10 17:09:06 +0300 | [diff] [blame] | 46 | |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 47 | # Enable grub menu using updated config below |
| 48 | - update-grub |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 49 | |
Dennis Dmitriev | 5f71f9e | 2018-10-19 13:02:43 +0300 | [diff] [blame] | 50 | - mkdir -p /srv/salt/reclass/nodes |
| 51 | - systemctl enable salt-master |
| 52 | - systemctl enable salt-minion |
| 53 | - systemctl start salt-master |
| 54 | - systemctl start salt-minion |
| 55 | - salt-call -l info --timeout=120 test.ping |
| 56 | |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 57 | write_files: |
Dennis Dmitriev | cf77780 | 2018-02-14 18:09:55 +0200 | [diff] [blame] | 58 | - path: /etc/default/grub.d/97-enable-grub-menu.cfg |
| 59 | content: | |
| 60 | GRUB_RECORDFAIL_TIMEOUT=30 |
| 61 | GRUB_TIMEOUT=3 |
| 62 | GRUB_TIMEOUT_STYLE=menu |
| 63 | |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 64 | - path: /etc/network/interfaces |
| 65 | content: | |
| 66 | auto ens3 |
| 67 | iface ens3 inet dhcp |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 68 | |
Tatyana Leontovich | d8bf14f | 2017-04-19 12:20:50 +0300 | [diff] [blame] | 69 | - path: /root/.ssh/config |
| 70 | owner: root:root |
| 71 | permissions: '0600' |
| 72 | content: | |
| 73 | Host * |
| 74 | ServerAliveInterval 300 |
| 75 | ServerAliveCountMax 10 |
| 76 | StrictHostKeyChecking no |
| 77 | UserKnownHostsFile /dev/null |