blob: 4983612a4d108e3e8cf021a04a8e9153cca5c49b [file] [log] [blame]
Dennis Dmitriev8ed27882018-01-31 23:23:19 +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 Dmitrievcf777802018-02-14 18:09:55 +020021 # # Block access to SSH while node is preparing
22 # - cloud-init-per once sudo iptables -A INPUT -p tcp --dport 22 -j DROP
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020023 # 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:
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +020030 - if lvs vg0; then pvresize /dev/vda3; fi
31 - if lvs vg0; then /usr/bin/growlvm.py --image-layout-file /usr/share/growlvm/image-layout.yml; fi
32
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020033 - export TERM=linux
34 - export LANG=C
35 # Configure dhclient
36 - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
37 - sudo resolvconf -u
38
39 # Enable grub menu using updated config below
40 - update-grub
41
42 # Prepare network connection
43 - sudo ifup {interface_name}
44 #- sudo route add default gw {gateway} {interface_name}
45
46 # Create swap
47 - fallocate -l 4G /swapfile
48 - chmod 600 /swapfile
49 - mkswap /swapfile
50 - swapon /swapfile
51 - echo "/swapfile none swap defaults 0 0" >> /etc/fstab
52
53
54 ############## TCP Cloud cfg01 node ##################
55 #- sleep 120
Dennis Dmitrievcf777802018-02-14 18:09:55 +020056 # - echo "Preparing base OS"
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020057 - echo "nameserver 172.18.208.44" > /etc/resolv.conf;
Oleksii Butenko336e4412018-05-21 14:59:27 +030058 # - echo "nameserver 8.8.8.8" >> /etc/resolv.conf;
Dennis Dmitrievcf777802018-02-14 18:09:55 +020059 # - which wget >/dev/null || (apt-get update; apt-get install -y wget)
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020060
Oleksii Butenko336e4412018-05-21 14:59:27 +030061 # Configure Ubuntu mirrors
Dennis Dmitrievcf777802018-02-14 18:09:55 +020062 # - echo "deb [arch=amd64] http://mirror.mirantis.com/{{ REPOSITORY_SUITE }}/ubuntu/ xenial main restricted universe" > /etc/apt/sources.list
63 # - echo "deb [arch=amd64] http://mirror.mirantis.com/{{ REPOSITORY_SUITE }}/ubuntu/ xenial-updates main restricted universe" >> /etc/apt/sources.list
64 # - echo "deb [arch=amd64] http://mirror.mirantis.com/{{ REPOSITORY_SUITE }}/ubuntu/ xenial-security main restricted universe" >> /etc/apt/sources.list
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020065
Dennis Dmitrievcf777802018-02-14 18:09:55 +020066 # - echo "deb [arch=amd64] http://apt.mirantis.com/xenial {{ REPOSITORY_SUITE }} salt extra" > /etc/apt/sources.list.d/mcp_salt.list;
67 # - wget -O - http://apt.mirantis.com/public.gpg | apt-key add -;
68 # - echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list;
69 # - wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -;
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020070
Dennis Dmitrievcf777802018-02-14 18:09:55 +020071 # - apt-get clean
72 # - eatmydata apt-get update && apt-get -y upgrade
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020073
Oleksii Butenko336e4412018-05-21 14:59:27 +030074 # Install common packages
Dennis Dmitrievcf777802018-02-14 18:09:55 +020075 # - eatmydata apt-get install -y python-pip git curl tmux byobu iputils-ping traceroute htop tree mc
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020076
Oleksii Butenko336e4412018-05-21 14:59:27 +030077 # Install salt-minion and stop it until it is configured
Dennis Dmitrievcf777802018-02-14 18:09:55 +020078 # - eatmydata apt-get install -y salt-minion && service salt-minion stop
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020079
Oleksii Butenko336e4412018-05-21 14:59:27 +030080 # Install latest kernel
Dennis Dmitrievcf777802018-02-14 18:09:55 +020081 # - eatmydata apt-get install -y {{ os_env('LINUX_KERNEL_HWE_PACKAGE_NAME', 'linux-image-extra-4.10.0-42-generic') }}
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020082
83 ########################################################
84 # Node is ready, allow SSH access
85 #- echo "Allow SSH access ..."
86 #- sudo iptables -D INPUT -p tcp --dport 22 -j DROP
Dennis Dmitrievcf777802018-02-14 18:09:55 +020087 # - reboot
Dennis Dmitriev8ed27882018-01-31 23:23:19 +020088 ########################################################
89
90 write_files:
91 - path: /etc/default/grub.d/97-enable-grub-menu.cfg
92 content: |
93 GRUB_RECORDFAIL_TIMEOUT=30
94 GRUB_TIMEOUT=3
95 GRUB_TIMEOUT_STYLE=menu
96
97 - path: /etc/network/interfaces
98 content: |
99 # The loopback network interface
100 auto lo
101 iface lo inet loopback
102 auto {interface_name}
Oleksii Butenko336e4412018-05-21 14:59:27 +0300103 iface {interface_name} inet dhcp
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +0200104
105 - path: /usr/share/growlvm/image-layout.yml
106 content: |
107 root:
Dennis Dmitrievc79f2282019-01-21 13:52:19 +0200108 size: '30%VG'
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +0200109 home:
Dennis Dmitrievc79f2282019-01-21 13:52:19 +0200110 size: '1G'
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +0200111 var_log:
Dennis Dmitrievc79f2282019-01-21 13:52:19 +0200112 size: '11%VG'
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +0200113 var_log_audit:
Dennis Dmitrievc79f2282019-01-21 13:52:19 +0200114 size: '5G'
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +0200115 var_tmp:
Dennis Dmitrievc79f2282019-01-21 13:52:19 +0200116 size: '11%VG'
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +0200117 tmp:
Dennis Dmitrievc79f2282019-01-21 13:52:19 +0200118 size: '5G'
Dennis Dmitriev752c1bf2018-12-19 13:05:16 +0200119 owner: root:root
120
121 growpart:
122 mode: auto
123 devices:
124 - '/'
125 - '/dev/vda3'
126 ignore_growroot_disabled: false