Dennis Dmitriev | 010f4cd | 2016-11-01 20:43:51 +0200 | [diff] [blame] | 1 | # Install salt to the config node |
| 2 | - description: Configure tcpcloud repository on the cfg01 node |
| 3 | cmd: echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security extra tcp tcp-salt' > /etc/apt/sources.list; |
| 4 | echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty tcp-salt' >> /etc/apt/sources.list; |
| 5 | wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add - |
| 6 | node_name: cfg01.mk22-lab-advanced.local |
| 7 | retry: {count: 1, delay: 1} |
| 8 | skip_fail: false |
| 9 | |
| 10 | #- description: Configure tcpcloud and saltstack repositories on the rest of nodes |
| 11 | # cmd: echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp tcp-salt' > /etc/apt/sources.list; |
| 12 | # wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add - ; |
| 13 | # echo 'deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest trusty main' > /etc/apt/sources.list.d/saltstack.list; |
| 14 | # wget -O - https://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - |
| 15 | # node_name: *** |
| 16 | # retry: {count: 1, delay: 1} |
| 17 | # skip_fail: false |
| 18 | |
| 19 | - description: Update packages on cfg01 |
| 20 | cmd: apt-get clean; apt-get update && apt-get -y upgrade |
| 21 | node_name: cfg01.mk22-lab-advanced.local |
| 22 | retry: {count: 3, delay: 10} |
| 23 | skip_fail: false |
| 24 | |
| 25 | - description: Install common packages on cfg01 |
| 26 | cmd: apt-get install -y python-pip wget curl tmux byobu iputils-ping traceroute htop tree |
| 27 | node_name: cfg01.mk22-lab-advanced.local |
| 28 | retry: {count: 3, delay: 10} |
| 29 | skip_fail: false |
| 30 | |
| 31 | - description: Install salt formulas, master and minion on cfg01 |
| 32 | cmd: apt-get install -y salt-formula-* salt-master salt-minion reclass |
| 33 | node_name: cfg01.mk22-lab-advanced.local |
| 34 | retry: {count: 3, delay: 10} |
| 35 | skip_fail: false |
| 36 | |
| 37 | - description: Configure salt-master on cfg01 |
| 38 | cmd: | |
| 39 | cat << 'EOF' >> /etc/salt/master.d/master.conf |
| 40 | file_roots: |
| 41 | base: |
| 42 | - /usr/share/salt-formulas/env |
| 43 | pillar_opts: False |
| 44 | open_mode: True |
| 45 | reclass: &reclass |
| 46 | storage_type: yaml_fs |
| 47 | inventory_base_uri: /srv/salt/reclass |
| 48 | ext_pillar: |
| 49 | - reclass: *reclass |
| 50 | master_tops: |
| 51 | reclass: *reclass |
| 52 | EOF |
| 53 | node_name: cfg01.mk22-lab-advanced.local |
| 54 | retry: {count: 1, delay: 1} |
| 55 | skip_fail: false |
| 56 | |
| 57 | - description: Configure GIT settings and certificates |
| 58 | cmd: touch /root/.git_trusted_certs.pem; |
| 59 | for server in git.tcpcloud.eu github.com; do |
| 60 | openssl s_client -showcerts -connect $server:443 </dev/null |
| 61 | | openssl x509 -outform PEM |
| 62 | >> /root/.git_trusted_certs.pem; |
| 63 | done; |
| 64 | HOME=/root git config --global http.sslCAInfo /root/.git_trusted_certs.pem; |
| 65 | HOME=/root git config --global user.email "tcp-qa@example.com"; |
| 66 | HOME=/root git config --global user.name "TCP QA"; |
| 67 | node_name: cfg01.mk22-lab-advanced.local |
| 68 | retry: {count: 1, delay: 1} |
| 69 | skip_fail: false |
| 70 | |
| 71 | - description: Clone reclass models and perform a workaround for https://mirantis.jira.com/browse/PROD-8078 |
| 72 | cmd: | |
Dennis Dmitriev | 9cc4ca3 | 2016-11-03 13:50:45 +0200 | [diff] [blame] | 73 | git clone https://github.com/Mirantis/mk-lab-salt-model.git /srv/salt/reclass -b dash; |
Dennis Dmitriev | 010f4cd | 2016-11-01 20:43:51 +0200 | [diff] [blame] | 74 | cat << 'EOF' >> /srv/salt/reclass/nodes/control/cfg01.mk22-lab-advanced.local.yml |
| 75 | # local storage |
| 76 | reclass: |
| 77 | storage: |
| 78 | data_source: |
| 79 | engine: local |
| 80 | EOF |
| 81 | sed -i '/nagios/d' /srv/salt/reclass/classes/system/salt/master/formula/pkg/stacklight.yml |
| 82 | cd /srv/salt/reclass; git add -A;git commit -m"use dash repo"; |
| 83 | node_name: cfg01.mk22-lab-advanced.local |
| 84 | retry: {count: 1, delay: 1} |
| 85 | skip_fail: false |
| 86 | |
| 87 | - description: Configure reclass |
| 88 | cmd: | |
| 89 | mkdir -p /srv/salt/reclass/classes/service; |
| 90 | for i in /usr/share/salt-formulas/reclass/service/*; do |
| 91 | ln -s $i /srv/salt/reclass/classes/service/; |
| 92 | done; |
| 93 | [ ! -d /etc/reclass ] && mkdir /etc/reclass; |
| 94 | cat << 'EOF' >> /etc/reclass/reclass-config.yml |
| 95 | storage_type: yaml_fs |
| 96 | pretty_print: True |
| 97 | output: yaml |
| 98 | inventory_base_uri: /srv/salt/reclass |
| 99 | EOF |
| 100 | node_name: cfg01.mk22-lab-advanced.local |
| 101 | retry: {count: 1, delay: 1} |
| 102 | skip_fail: false |
| 103 | |
| 104 | - description: Configure salt-minion on cfg01 |
| 105 | cmd: | |
| 106 | [ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d; |
| 107 | cat << "EOF" >> /etc/salt/minion.d/minion.conf |
| 108 | id: cfg01.mk22-lab-advanced.local |
| 109 | master: localhost |
| 110 | EOF |
| 111 | node_name: cfg01.mk22-lab-advanced.local |
| 112 | retry: {count: 1, delay: 1} |
| 113 | skip_fail: false |
| 114 | |
| 115 | - description: Restarting salt services with workarounds |
| 116 | cmd: service salt-master restart; |
| 117 | sleep 60; |
| 118 | rm -f /etc/salt/pki/minion/minion_master.pub; |
| 119 | service salt-minion restart; |
| 120 | reclass -n cfg01.mk22-lab-advanced.local; |
| 121 | node_name: cfg01.mk22-lab-advanced.local |
| 122 | retry: {count: 3, delay: 10} |
| 123 | skip_fail: false |
| 124 | |
| 125 | |
| 126 | # Prepare salt services and nodes settings |
| 127 | - description: Run 'linux' formula on cfg01 |
| 128 | cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls |
| 129 | linux |
| 130 | node_name: cfg01.mk22-lab-advanced.local |
| 131 | retry: {count: 3, delay: 5} |
| 132 | skip_fail: false |
| 133 | |
| 134 | - description: Run 'openssh' formula on cfg01 |
| 135 | cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls |
| 136 | openssh;sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config |
| 137 | && service ssh restart |
| 138 | node_name: cfg01.mk22-lab-advanced.local |
| 139 | retry: {count: 3, delay: 5} |
| 140 | skip_fail: false |
| 141 | |
| 142 | - description: '*Workaround* of the bug https://mirantis.jira.com/browse/PROD-7962' |
| 143 | cmd: echo ' StrictHostKeyChecking no' >> /root/.ssh/config |
| 144 | node_name: cfg01.mk22-lab-advanced.local |
| 145 | retry: {count: 1, delay: 1} |
| 146 | skip_fail: false |
| 147 | |
| 148 | - description: Run 'salt' formula on cfg01 |
| 149 | cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls |
| 150 | salt |
| 151 | node_name: cfg01.mk22-lab-advanced.local |
| 152 | retry: {count: 3, delay: 5} |
| 153 | skip_fail: true |
| 154 | |
| 155 | - description: Accept salt keys from all the nodes |
| 156 | cmd: salt-key -A -y |
| 157 | node_name: cfg01.mk22-lab-advanced.local |
| 158 | retry: {count: 1, delay: 5} |
| 159 | skip_fail: false |
| 160 | |
| 161 | - description: Generate inventory for all the nodes to the /srv/salt/reclass/nodes/_generated |
| 162 | cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls |
| 163 | reclass.storage |
| 164 | node_name: cfg01.mk22-lab-advanced.local |
| 165 | retry: {count: 3, delay: 5} |
| 166 | skip_fail: false |
| 167 | |
| 168 | - description: Refresh pillars on all minions |
| 169 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 170 | node_name: cfg01.mk22-lab-advanced.local |
| 171 | retry: {count: 3, delay: 5} |
| 172 | skip_fail: false |
| 173 | |
| 174 | # Bootstrap all nodes |
| 175 | - description: Configure linux on controllers |
| 176 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls |
| 177 | linux |
| 178 | node_name: cfg01.mk22-lab-advanced.local |
| 179 | retry: {count: 5, delay: 5} |
| 180 | skip_fail: false |
| 181 | |
| 182 | - description: Configure openssh on controllers |
| 183 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not |
| 184 | cfg*' state.sls openssh;salt --hard-crash --state-output=mixed --state-verbose=False |
| 185 | -C '* and not cfg*' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication |
| 186 | yes/' /etc/ssh/sshd_config && service ssh restart" |
| 187 | node_name: cfg01.mk22-lab-advanced.local |
| 188 | retry: {count: 3, delay: 5} |
| 189 | skip_fail: false |
| 190 | |
| 191 | - description: '*Workaround* for the bug https://mirantis.jira.com/browse/PROD-8025' |
| 192 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'apt-get |
| 193 | update && apt-get -y upgrade' |
| 194 | node_name: cfg01.mk22-lab-advanced.local |
| 195 | retry: {count: 3, delay: 5} |
| 196 | skip_fail: false |
| 197 | |
| 198 | - description: '*Workaround* for the bug https://mirantis.jira.com/browse/PROD-8021' |
| 199 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'apt-get |
| 200 | -y install linux-image-extra-$(uname -r)' |
| 201 | node_name: cfg01.mk22-lab-advanced.local |
| 202 | retry: {count: 3, delay: 5} |
| 203 | skip_fail: false |
| 204 | |
| 205 | - description: '*Workaround* for the bug https://mirantis.jira.com/browse/PROD-8025' |
| 206 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'apt-get |
| 207 | -y install python-requests' |
| 208 | node_name: cfg01.mk22-lab-advanced.local |
| 209 | retry: {count: 3, delay: 5} |
| 210 | skip_fail: false |
| 211 | |
Dennis Dmitriev | 9cc4ca3 | 2016-11-03 13:50:45 +0200 | [diff] [blame] | 212 | #- description: '*Workaround* of the bug https://mirantis.jira.com/browse/PROD-8063' |
| 213 | # cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'dhclient |
| 214 | # -r;dhclient' |
| 215 | # node_name: cfg01.mk22-lab-advanced.local |
| 216 | # retry: {count: 1, delay: 1} |
| 217 | # skip_fail: false |
Dennis Dmitriev | 010f4cd | 2016-11-01 20:43:51 +0200 | [diff] [blame] | 218 | |
| 219 | - description: Configure salt.minion on controllers |
| 220 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls |
| 221 | salt.minion |
| 222 | node_name: cfg01.mk22-lab-advanced.local |
| 223 | retry: {count: 3, delay: 5} |
| 224 | skip_fail: false |
| 225 | |
| 226 | - description: Configure ntp on controllers |
| 227 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls |
| 228 | ntp |
| 229 | node_name: cfg01.mk22-lab-advanced.local |
| 230 | retry: {count: 5, delay: 10} |
| 231 | skip_fail: false |