blob: dcc77d2de92bc57ffcb898c4c0aafdf52228e7d2 [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}
Tatyana Leontovichb7404592017-04-07 11:52:28 +030039
40 # Create swap
41 - fallocate -l 4G /swapfile
42 - chmod 600 /swapfile
43 - mkswap /swapfile
44 - swapon /swapfile
45 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
46
47 ########################################################
48 # Node is ready, allow SSH access
49 - echo "Allow SSH access ..."
50 - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
51 ########################################################
52
53 ############## TCP Cloud cfg01 node ##################
54 #- sleep 120
55 - echo "Preparing base OS"
56 - which wget >/dev/null || (apt-get update; apt-get install -y wget)
57 - echo "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security extra tcp tcp-salt" > /etc/apt/sources.list
58 - wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
59 # saltstack repo is for minions that have the same version in the xenial and trusty (2016.3.3)
60 #- echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main" > /etc/apt/sources.list.d/saltstack.list
61 #- wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add -
62 - echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list
63 - wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -
64
65 - apt-get clean
66 - apt-get update
67 - apt-get -y upgrade
68
69 # Install common packages
70 - apt-get install -y python-pip git
71 - apt-get install -y curl tmux byobu iputils-ping traceroute htop tree
72
73 - apt-get install -y salt-minion
74
75 # To be configured from inventory/fuel-devops by operator or autotests
76 - 'echo "id: {hostname}" >> /etc/salt/minion'
77 - 'echo "master: 192.168.10.100" >> /etc/salt/minion'
78
79 - echo "Restarting minion service with workarounds..."
80 - rm -f /etc/salt/pki/minion/minion_master.pub
81 - service salt-minion restart
82 - sleep 5
83 - rm -f /etc/salt/pki/minion/minion_master.pub
84 - service salt-minion restart
85
86 #- echo "Showing node metadata..."
87 #- salt-call pillar.data
88
89 #- echo "Running complete state ..."
90 #- salt-call state.sls linux,openssh,salt
91
92 write_files:
93 - path: /etc/network/interfaces
94 content: |
95 auto ens3
96 iface ens3 inet dhcp
Tatyana Leontovichb7404592017-04-07 11:52:28 +030097