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