blob: 6076ffaabe3dd3225e0c56706b99f587e389e7e7 [file] [log] [blame]
Victor Ryzhenkina95d1732017-11-16 19:02:19 +04001| # 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:
Victor Ryzhenkina95d1732017-11-16 19:02:19 +040021 # 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 Dmitrievf00a3842018-01-24 16:44:26 +020033 - sudo ifdown ens3
Dennis Dmitriev002b8432018-01-25 03:26:14 +020034 - sudo ip r d default || true # remove existing default route to get it from dhcp
Victor Ryzhenkina95d1732017-11-16 19:02:19 +040035 - sudo ifup ens3
36 #- sudo route add default gw {gateway} {interface_name}
Dennis Dmitriev002b8432018-01-25 03:26:14 +020037 - sudo ifdown ens4
38 - sudo ifdown ens5
Victor Ryzhenkina95d1732017-11-16 19:02:19 +040039 - sudo ifup ens4
40 - sudo ifup ens5
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
49 ############## TCP Cloud cfg01 node ##################
50 #- sleep 120
51 - echo "Preparing base OS"
52
53 - echo "nameserver 172.18.208.44" >> /etc/resolv.conf;
Victor Ryzhenkina95d1732017-11-16 19:02:19 +040054 - which wget >/dev/null || (apt-get update; apt-get install -y wget);
55
56 - echo "deb [arch=amd64] http://apt.mirantis.com/xenial {{ REPOSITORY_SUITE }} salt extra" > /etc/apt/sources.list.d/mcp_salt.list;
57 - wget -O - http://apt.mirantis.com/public.gpg | apt-key add -;
Tatyana Leontovich4453dd62018-06-26 18:44:31 +030058 - echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/{{ SALT_VERSION }} xenial main" > /etc/apt/sources.list.d/saltstack.list;
59 - wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/{{ SALT_VERSION }}/SALTSTACK-GPG-KEY.pub | apt-key add -;
Victor Ryzhenkina95d1732017-11-16 19:02:19 +040060
61 - eatmydata apt-get clean && eatmydata apt-get update
62
63 # Install common packages
64 - eatmydata apt-get install -y python-pip git curl tmux byobu iputils-ping traceroute htop tree
65
Dennis Dmitriev5f71f9e2018-10-19 13:02:43 +030066 - mkdir -p /srv/salt/reclass/nodes
67 - systemctl enable salt-master
68 - systemctl enable salt-minion
69 - systemctl start salt-master
70 - systemctl start salt-minion
71 - salt-call -l info --timeout=120 test.ping
Victor Ryzhenkina95d1732017-11-16 19:02:19 +040072
73 write_files:
74 - path: /etc/network/interfaces
75 content: |
76 auto ens3
77 iface ens3 inet dhcp
78 auto ens4
79 iface ens4 inet dhcp
80 auto ens5
81 iface ens5 inet dhcp
82
83 - path: /root/.ssh/config
84 owner: root:root
85 permissions: '0600'
86 content: |
87 Host *
88 ServerAliveInterval 300
89 ServerAliveCountMax 10
90 StrictHostKeyChecking no
91 UserKnownHostsFile /dev/null