Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 1 | | # 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: |
| 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: |
Dennis Dmitriev | 752c1bf | 2018-12-19 13:05:16 +0200 | [diff] [blame^] | 30 | - 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 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 33 | - 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 |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 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 |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 52 | |
| 53 | |
| 54 | ############## TCP Cloud cfg01 node ################## |
| 55 | #- sleep 120 |
| 56 | # - echo "Preparing base OS" |
| 57 | - echo "nameserver 172.17.41.2" > /etc/resolv.conf; |
| 58 | # - which wget >/dev/null || (apt-get update; apt-get install -y wget) |
| 59 | |
| 60 | # Configure Ubuntu mirrors |
| 61 | # - echo "deb [arch=amd64] http://mirror.mirantis.com/{{ REPOSITORY_SUITE }}/ubuntu/ xenial main restricted universe" > /etc/apt/sources.list |
| 62 | # - echo "deb [arch=amd64] http://mirror.mirantis.com/{{ REPOSITORY_SUITE }}/ubuntu/ xenial-updates main restricted universe" >> /etc/apt/sources.list |
| 63 | # - echo "deb [arch=amd64] http://mirror.mirantis.com/{{ REPOSITORY_SUITE }}/ubuntu/ xenial-security main restricted universe" >> /etc/apt/sources.list |
| 64 | |
| 65 | # - echo "deb [arch=amd64] http://apt.mirantis.com/xenial {{ REPOSITORY_SUITE }} salt extra" > /etc/apt/sources.list.d/mcp_salt.list; |
| 66 | # - wget -O - http://apt.mirantis.com/public.gpg | apt-key add -; |
| 67 | # - echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list; |
| 68 | # - wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -; |
| 69 | |
| 70 | # - apt-get clean |
| 71 | # - eatmydata apt-get update && apt-get -y upgrade |
| 72 | |
| 73 | # Install common packages |
| 74 | # - eatmydata apt-get install -y python-pip git curl tmux byobu iputils-ping traceroute htop tree mc |
| 75 | |
| 76 | # Install salt-minion and stop it until it is configured |
| 77 | # - eatmydata apt-get install -y salt-minion && service salt-minion stop |
| 78 | |
| 79 | ######################################################## |
| 80 | # Node is ready, allow SSH access |
| 81 | # - echo "Allow SSH access ..." |
| 82 | # - sudo iptables -D INPUT -p tcp --dport 22 -j DROP |
| 83 | ######################################################## |
| 84 | |
| 85 | write_files: |
| 86 | - path: /etc/default/grub.d/97-enable-grub-menu.cfg |
| 87 | content: | |
| 88 | GRUB_RECORDFAIL_TIMEOUT=30 |
| 89 | GRUB_TIMEOUT=3 |
| 90 | GRUB_TIMEOUT_STYLE=menu |
| 91 | |
| 92 | - path: /etc/network/interfaces |
| 93 | content: | |
| 94 | # The loopback network interface |
| 95 | auto lo |
| 96 | iface lo inet loopback |
| 97 | auto {interface_name} |
| 98 | iface {interface_name} inet dhcp |
Dennis Dmitriev | 752c1bf | 2018-12-19 13:05:16 +0200 | [diff] [blame^] | 99 | |
| 100 | - path: /usr/share/growlvm/image-layout.yml |
| 101 | content: | |
| 102 | root: |
| 103 | size: '50%VG' |
| 104 | home: |
| 105 | size: '100M' |
| 106 | var_log: |
| 107 | size: '15%VG' |
| 108 | var_log_audit: |
| 109 | size: '500M' |
| 110 | var_tmp: |
| 111 | size: '500M' |
| 112 | tmp: |
| 113 | size: '500M' |
| 114 | owner: root:root |
| 115 | |
| 116 | growpart: |
| 117 | mode: auto |
| 118 | devices: |
| 119 | - '/' |
| 120 | - '/dev/vda3' |
| 121 | ignore_growroot_disabled: false |