Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [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: |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 21 | # Enable root access |
Dennis Dmitriev | bf6e4e0 | 2018-03-26 20:37:44 +0300 | [diff] [blame] | 22 | - cloud-init-per once sudo sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config |
| 23 | - cloud-init-per once sudo service sshd restart |
Dennis Dmitriev | f4e6efc | 2018-03-26 06:15:10 -0500 | [diff] [blame] | 24 | |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 25 | output: |
| 26 | all: '| tee -a /var/log/cloud-init-output.log /dev/tty0' |
| 27 | |
| 28 | runcmd: |
| 29 | # Prepare network connection |
| 30 | - sudo ifdown ens3 |
Dennis Dmitriev | 5f71f9e | 2018-10-19 13:02:43 +0300 | [diff] [blame^] | 31 | - sudo ifdown ens4 |
| 32 | - sudo ip r d default || true # remove existing default route to get it from dhcp |
Dennis Dmitriev | bf6e4e0 | 2018-03-26 20:37:44 +0300 | [diff] [blame] | 33 | - sudo ifup ens3 |
Dennis Dmitriev | 5f71f9e | 2018-10-19 13:02:43 +0300 | [diff] [blame^] | 34 | - sudo ifup ens4 |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 35 | #- sudo route add default gw {gateway} {interface_name} |
| 36 | |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 37 | # Enable grub menu using updated config below |
| 38 | - update-grub |
| 39 | |
Dennis Dmitriev | 5f71f9e | 2018-10-19 13:02:43 +0300 | [diff] [blame^] | 40 | - mkdir -p /srv/salt/reclass/nodes |
| 41 | - systemctl enable salt-master |
| 42 | - systemctl enable salt-minion |
| 43 | - systemctl start salt-master |
| 44 | - systemctl start salt-minion |
| 45 | - salt-call -l info --timeout=120 test.ping |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 46 | # Create swap |
| 47 | #- fallocate -l 16G /swapfile |
| 48 | #- chmod 600 /swapfile |
| 49 | #- mkswap /swapfile |
| 50 | #- swapon /swapfile |
| 51 | #- echo "/swapfile none swap defaults 0 0" >> /etc/fstab |
| 52 | |
| 53 | ############## TCP Cloud cfg01 node ################## |
| 54 | - echo "Preparing base OS" |
| 55 | |
Dennis Dmitriev | 5f71f9e | 2018-10-19 13:02:43 +0300 | [diff] [blame^] | 56 | - echo "nameserver 172.18.208.44" > /etc/resolv.conf; |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 57 | |
| 58 | # Ensure that the salt-master service is ready to receive requests |
| 59 | - salt-key -y -D |
Dennis Dmitriev | f4e6efc | 2018-03-26 06:15:10 -0500 | [diff] [blame] | 60 | |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 61 | write_files: |
| 62 | - path: /etc/default/grub.d/97-enable-grub-menu.cfg |
| 63 | content: | |
| 64 | GRUB_RECORDFAIL_TIMEOUT=30 |
| 65 | GRUB_TIMEOUT=3 |
| 66 | GRUB_TIMEOUT_STYLE=menu |
| 67 | |
| 68 | - path: /etc/network/interfaces |
| 69 | content: | |
| 70 | auto ens3 |
| 71 | iface ens3 inet dhcp |
Dennis Dmitriev | bf6e4e0 | 2018-03-26 20:37:44 +0300 | [diff] [blame] | 72 | auto ens4 |
| 73 | iface ens4 inet dhcp |
Dennis Dmitriev | 8555996 | 2018-01-30 15:35:51 +0200 | [diff] [blame] | 74 | |
| 75 | - path: /root/.ssh/config |
| 76 | owner: root:root |
| 77 | permissions: '0600' |
| 78 | content: | |
| 79 | Host * |
| 80 | ServerAliveInterval 300 |
| 81 | ServerAliveCountMax 10 |
| 82 | StrictHostKeyChecking no |
| 83 | UserKnownHostsFile /dev/null |
| 84 | |
| 85 | # Fix hardcoded IP address in the minion.conf |
| 86 | - path: /etc/salt/minion.d/minion.conf |
| 87 | content: | |
| 88 | master: 127.0.0.1 |
| 89 | id: cfg01.{{ DOMAIN_NAME }} |