blob: ad2c39be7016a640e8cdef5c5c5edaab7fe8655c [file] [log] [blame]
Tatyana Leontovichb7404592017-04-07 11:52:28 +03001| # 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 Panchenkodb0a97f2017-06-27 19:09:13 +030010 {% for key in config.underlay.ssh_keys %}
11 - ssh-rsa {{ key['public'] }}
12 {% endfor %}
Tatyana Leontovichb7404592017-04-07 11:52:28 +030013
14 disable_root: false
15 chpasswd:
16 list: |
17 root:r00tme
18 expire: False
19
20 bootcmd:
21 # Block access to SSH while node is preparing
22 - cloud-init-per once sudo iptables -A INPUT -p tcp --dport 22 -j DROP
23 # Enable root access
24 - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
25 - service sshd restart
26 output:
27 all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
28
29 runcmd:
30 - export TERM=linux
31 - export LANG=C
32 # Configure dhclient
33 - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
34 - sudo resolvconf -u
35
36 # Prepare network connection
37 - sudo ifup ens3
38 #- sudo route add default gw {gateway} {interface_name}
39 - sudo ifup ens4
40
41 # Create swap
42 - fallocate -l 4G /swapfile
43 - chmod 600 /swapfile
44 - mkswap /swapfile
45 - swapon /swapfile
46 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
47
48 ########################################################
49 # Node is ready, allow SSH access
50 - echo "Allow SSH access ..."
51 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
52 ########################################################
53
54 ############## TCP Cloud cfg01 node ##################
55 #- sleep 120
56 - echo "Preparing base OS"
57 - which wget >/dev/null || (apt-get update; apt-get install -y wget)
58 - echo "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security extra tcp tcp-salt" > /etc/apt/sources.list
59 - wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
60 # saltstack repo is for minions that have the same version in the xenial and trusty (2016.3.3)
61 #- echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main" > /etc/apt/sources.list.d/saltstack.list
62 #- wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -
63 - echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list
64 - wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -
65
66 - apt-get clean
67 - apt-get update
68 - apt-get -y upgrade
69
70 # Install common packages
71 - apt-get install -y python-pip git
72 - apt-get install -y curl tmux byobu iputils-ping traceroute htop tree
73
74 - apt-get install -y salt-minion
75
76 # To be configured from inventory/fuel-devops by operator or autotests
77 - 'echo "id: {hostname}" >> /etc/salt/minion'
78 - 'echo "master: 192.168.10.100" >> /etc/salt/minion'
79
80 - echo "Restarting minion service with workarounds..."
81 - rm -f /etc/salt/pki/minion/minion_master.pub
82 - service salt-minion restart
83 - sleep 5
84 - rm -f /etc/salt/pki/minion/minion_master.pub
85 - service salt-minion restart
86
87 #- echo "Showing node metadata..."
88 #- salt-call pillar.data
89
90 #- echo "Running complete state ..."
91 #- salt-call state.sls linux,openssh,salt
92
93 write_files:
94 - path: /etc/network/interfaces
95 content: |
96 auto ens3
97 iface ens3 inet dhcp
98 auto ens4
99 iface ens4 inet dhcp
100