blob: 695e537ffef13cdd8385bd1d8343f4b71c23bdbd [file] [log] [blame]
Dennis Dmitriev85559962018-01-30 15:35:51 +02001| # 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 Dmitriev85559962018-01-30 15:35:51 +020021 # Enable root access
Dennis Dmitrievbf6e4e02018-03-26 20:37:44 +030022 - 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 Dmitrievf4e6efc2018-03-26 06:15:10 -050024
Dennis Dmitriev85559962018-01-30 15:35:51 +020025 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 Dmitriev5f71f9e2018-10-19 13:02:43 +030031 - sudo ifdown ens4
32 - sudo ip r d default || true # remove existing default route to get it from dhcp
Dennis Dmitrievbf6e4e02018-03-26 20:37:44 +030033 - sudo ifup ens3
Dennis Dmitriev5f71f9e2018-10-19 13:02:43 +030034 - sudo ifup ens4
Dennis Dmitriev85559962018-01-30 15:35:51 +020035 #- sudo route add default gw {gateway} {interface_name}
36
Dennis Dmitriev85559962018-01-30 15:35:51 +020037 # Enable grub menu using updated config below
38 - update-grub
39
Dennis Dmitriev5f71f9e2018-10-19 13:02:43 +030040 - 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 Dmitriev85559962018-01-30 15:35:51 +020046 # 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 Dmitriev5f71f9e2018-10-19 13:02:43 +030056 - echo "nameserver 172.18.208.44" > /etc/resolv.conf;
Dennis Dmitriev85559962018-01-30 15:35:51 +020057
58 # Ensure that the salt-master service is ready to receive requests
59 - salt-key -y -D
Dennis Dmitrievf4e6efc2018-03-26 06:15:10 -050060
Dennis Dmitriev85559962018-01-30 15:35:51 +020061 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 Dmitrievbf6e4e02018-03-26 20:37:44 +030072 auto ens4
73 iface ens4 inet dhcp
Dennis Dmitriev85559962018-01-30 15:35:51 +020074
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 }}