Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +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: |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 6 | - name: root |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 7 | sudo: ALL=(ALL) NOPASSWD:ALL |
| 8 | shell: /bin/bash |
| 9 | ssh_authorized_keys: |
| 10 | - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGwjUlYn9UsmWmAGSuEA2sICad7WqxgsJR0HKcMbbxi0tn96h4Cq2iGYmzlJ48egLm5R5pxyWnFvL4b/2zb+kKTPCMwRc9nv7xEGosEFNQEoSDd+gYu2CO0dgS2bX/7m2DXmzvhqPjxWQUXXsb0OYAS1r9Es65FE8y4rLaegz8V35xfH45bTCA0W8VSKh264XtGz12hacqsttE/UvyjJTZe+/XV+xJy3WAWxe8J/MuW1VqbqNewTmpTE/LJU8i6pG4msU6+wH99UvsGAOKQOduynUHKWG3VZg5YCjpbbV/t/pfW/vHB3b3jiifQmNhulyiG/CNnSQ5BahtV/7qPsYt vagrant@cfg01 |
| 11 | |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 12 | disable_root: false |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 13 | chpasswd: |
| 14 | list: | |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 15 | root:r00tme |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 16 | expire: False |
| 17 | |
| 18 | bootcmd: |
| 19 | # Block access to SSH while node is preparing |
| 20 | - cloud-init-per once sudo iptables -A INPUT -p tcp --dport 22 -j DROP |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 21 | # Enable root access |
Dennis Dmitriev | 3bf410e | 2016-10-26 20:22:04 +0300 | [diff] [blame^] | 22 | - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 23 | - service sshd restart |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 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 | |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 32 | # Prepare network connection |
| 33 | - sudo ifup {interface_name} |
| 34 | - sudo route add default gw {gateway} {interface_name} |
| 35 | - sudo ifup eth1 |
| 36 | |
| 37 | ############## TCP Cloud cfg01 node ################## |
| 38 | - echo "Preparing base OS" |
| 39 | - which wget >/dev/null || (apt-get update; apt-get install -y wget) |
| 40 | |
Dennis Dmitriev | 3bf410e | 2016-10-26 20:22:04 +0300 | [diff] [blame^] | 41 | - echo "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security extra tcp tcp-salt" > /etc/apt/sources.list |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 42 | - wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add - |
| 43 | |
| 44 | - apt-get clean |
| 45 | - apt-get update |
| 46 | - apt-get -y upgrade |
| 47 | |
| 48 | # Install common packages |
| 49 | - apt-get install -y python-pip |
| 50 | - apt-get install -y curl tmux byobu iputils-ping traceroute htop tree |
| 51 | |
| 52 | - echo "Configuring salt master ..." |
| 53 | - apt-get install -y salt-master reclass |
| 54 | - apt-get install -y salt-formula-* |
| 55 | |
| 56 | - | |
| 57 | cat << 'EOF' >> /etc/salt/master.d/master.conf |
| 58 | file_roots: |
| 59 | base: |
| 60 | - /usr/share/salt-formulas/env |
| 61 | pillar_opts: False |
| 62 | open_mode: True |
| 63 | reclass: &reclass |
| 64 | storage_type: yaml_fs |
| 65 | inventory_base_uri: /srv/salt/reclass |
| 66 | ext_pillar: |
| 67 | - reclass: *reclass |
| 68 | master_tops: |
| 69 | reclass: *reclass |
| 70 | EOF |
| 71 | |
Dennis Dmitriev | 45738b9 | 2016-10-20 18:11:15 +0300 | [diff] [blame] | 72 | - echo "Configure git settings and certificate" |
| 73 | - touch /root/.git_trusted_certs.pem |
| 74 | - for server in git.tcpcloud.eu github.com; do openssl s_client -showcerts -connect $server:443 </dev/null | openssl x509 -outform PEM >> /root/.git_trusted_certs.pem; done |
| 75 | - HOME=/root git config --global http.sslCAInfo /root/.git_trusted_certs.pem |
| 76 | - HOME=/root git config --global user.email "tcp-qa@example.com" |
| 77 | - HOME=/root git config --global user.name "TCP QA" |
| 78 | |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 79 | - echo "Configuring reclass ..." |
| 80 | - git clone https://github.com/Mirantis/mk-lab-salt-model.git /srv/salt/reclass -b master |
| 81 | |
| 82 | - mkdir -p /srv/salt/reclass/classes/service |
| 83 | - for i in /usr/share/salt-formulas/reclass/service/*; do ln -s $i /srv/salt/reclass/classes/service/; done |
| 84 | |
| 85 | - '[ ! -d /etc/reclass ] && mkdir /etc/reclass' |
| 86 | - | |
| 87 | cat << 'EOF' >> /etc/reclass/reclass-config.yml |
| 88 | storage_type: yaml_fs |
| 89 | pretty_print: True |
| 90 | output: yaml |
| 91 | inventory_base_uri: /srv/salt/reclass |
| 92 | EOF |
| 93 | |
| 94 | - echo "Configuring salt minion ..." |
| 95 | - apt-get install -y salt-minion |
| 96 | - '[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d' |
| 97 | |
| 98 | - | |
| 99 | cat << "EOF" >> /etc/salt/minion.d/minion.conf |
| 100 | id: {hostname} |
| 101 | master: localhost |
| 102 | EOF |
| 103 | |
Dennis Dmitriev | 45738b9 | 2016-10-20 18:11:15 +0300 | [diff] [blame] | 104 | - echo "Restarting services with workarounds..." |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 105 | - service salt-master restart |
Dennis Dmitriev | 3bf410e | 2016-10-26 20:22:04 +0300 | [diff] [blame^] | 106 | - sleep 60 |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 107 | - rm -f /etc/salt/pki/minion/minion_master.pub |
| 108 | - service salt-minion restart |
| 109 | |
| 110 | - echo "Showing system info and metadata ..." |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 111 | - salt-call --no-color grains.items |
| 112 | - salt-call --no-color pillar.data |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 113 | - reclass -n {hostname} |
| 114 | |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 115 | ######################################################## |
| 116 | # Node is ready, allow SSH access |
| 117 | - echo "Allow SSH access ..." |
| 118 | - sudo iptables -D INPUT -p tcp --dport 22 -j DROP |
| 119 | ######################################################## |
| 120 | |
| 121 | write_files: |
| 122 | - path: /etc/network/interfaces.d/99-tcp-tests.cfg |
| 123 | content: | |
| 124 | auto eth0 |
| 125 | iface eth0 inet dhcp |
| 126 | |
| 127 | # 2nd interface should be UP without IP address |
| 128 | auto eth1 |
Dennis Dmitriev | 45738b9 | 2016-10-20 18:11:15 +0300 | [diff] [blame] | 129 | iface eth1 inet dhcp |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 130 | |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 131 | - path: /root/.ssh/id_rsa |
| 132 | owner: root:root |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 133 | permissions: '0600' |
| 134 | content: | |
| 135 | -----BEGIN RSA PRIVATE KEY----- |
| 136 | MIIEpAIBAAKCAQEAxsI1JWJ/VLJlpgBkrhANrCAmne1qsYLCUdBynDG28YtLZ/eo |
| 137 | eAqtohmJs5SePHoC5uUeacclpxby+G/9s2/pCkzwjMEXPZ7+8RBqLBBTUBKEg3fo |
| 138 | GLtgjtHYEtm1/+5tg15s74aj48VkFF17G9DmAEta/RLOuRRPMuKy2noM/Fd+cXx+ |
| 139 | OW0wgNFvFUioduuF7Rs9doWnKrLbRP1L8oyU2Xvv11fsSct1gFsXvCfzLltVam6j |
| 140 | XsE5qUxPyyVPIuqRuJrFOvsB/fVL7BgDikDnbsp1Bylht1WYOWAo6W21f7f6X1v7 |
| 141 | xwd2944on0JjYbpcohvwjZ0kOQWobVf+6j7GLQIDAQABAoIBAF0tAAMlmLGY7CQU |
| 142 | /R3IctBlRhU1DpZmyTfXc1MbzzqO5Wu44yZbQyjBthcUrdWGEUQy1r4Z2OHq1T54 |
| 143 | KcPry6DDjuU9Q+rkVXmnC07a3GOmOq7zEEA/3zU01ImJvFNdb8NtCb6ELOKDT7Zo |
| 144 | WGUi2h/7M41+OqDzD2m4csYO/3Vvr12sMhn9BfwU4OPpL44A4PJiEryEAw9o5/j/ |
| 145 | 73eyPvgf6tkC4l0mMtfHB9tg/F++iH8fiEr1SMvHGIc9gZNmFYMrs2XfLkAejPfH |
| 146 | XrOyw6eqd+kluqw51gHhdeQYwBx6mfOkbhPHWU79FzpH5M1ikdfImZmPCxVf3Ykj |
| 147 | nxLoK9UCgYEA4c9agPb/OFyN00nnUMBxzQt1pErpOf/7QhnvNZThomzSV7PyefxF |
| 148 | H6G/VlS3gCcrWBCh7mqOSxGcNQwgudVqzUm7QXruQeg4nWcCGSxg7lGYSEf0MyWL |
| 149 | 5wrd+f9MoV/VV8udIPENjp96o5kwQEVRfsTBNwmk54kup2+br5q8re8CgYEA4VT8 |
| 150 | UeIN+plP6FjZYITI+SO/ou5goKIhfBrqa5gOXXPc2y6sIu9wBWCr+T7FAF/2gGhS |
| 151 | rpVx76zcmx05nwkxIlJh58+G3MVyUDFoWnrtL38vdkBSuOGgNfzcBsFpQvFs8WaW |
| 152 | otbuTtkPcXbVdYRr32/C620MxXhUO+svo3CLaaMCgYEA1rjlF8NHl+Gy31rkQg5t |
| 153 | aIxgFpVBR+zZkNa2d94V3Ozb65fqmALB/D1Dg6VVROB6P+i5AsyCeHHLd0oMCIof |
| 154 | YAyfqrlpvHRE+bAM98ESfyxJwVnipYwrh8z2nZYd2UoWxcCRrtRpjtipts2ha0w/ |
| 155 | HWudS2e5To5NNdxUT9y1VDMCgYEAxkQiE+ZkyGiXv+hVtLCBqX4EA9fdm9msvudr |
| 156 | 9qn/kcj9vrntanvlxEWQbCoH61GEsu2YOtdyPiKKpc1sQvwyiHGWhgK7NoxhDiC7 |
| 157 | IknhYxZ064ajgtu8PWS1MRiDhwypACt1Rej6HNSu2vZl0hZnWF2dU8tLHoHHFEXX |
| 158 | T+caNCMCgYBZpD6XBiiEXf0ikXYnXKOmbsyVG80V+yqfLo85qb2RW9TaviOSP43g |
| 159 | nB22ReMSHq2cOrs6VTTgfhxefBwzdDFbfKMf6ZU82jCNlpetAZOrhdMHUvcsjSQk |
| 160 | XKI6Ldfq6TU3xKujRHfGP+oQ6GLwVCL/kjGxOuSRLFGfRiiqYI3nww== |
| 161 | -----END RSA PRIVATE KEY----- |
| 162 | |
Dennis Dmitriev | 9512679 | 2016-10-18 17:03:30 +0300 | [diff] [blame] | 163 | - path: /root/.ssh/config |
| 164 | owner: root:root |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 165 | permissions: '0600' |
| 166 | content: | |
| 167 | Host * |
| 168 | ServerAliveInterval 300 |
| 169 | ServerAliveCountMax 10 |
| 170 | StrictHostKeyChecking no |
| 171 | UserKnownHostsFile /dev/null |