blob: b22a71d31e5df12b3d52caaabab6bb0d847884e6 [file] [log] [blame]
disc5298382016-11-23 16:03:33 +02001# Install salt to the config node
disf0924fb2016-12-03 04:01:12 +02002
disc5298382016-11-23 16:03:33 +02003- description: Configure tcpcloud repository on the cfg01 node
disfdaa0c92016-12-06 21:50:19 +02004 cmd: echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security extra tcp tcp-salt' > /etc/apt/sources.list;
disc5298382016-11-23 16:03:33 +02005 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 -;
disfdaa0c92016-12-06 21:50:19 +02007 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 -;
disc5298382016-11-23 16:03:33 +020011 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
disfdaa0c92016-12-06 21:50:19 +020037 # 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
disc5298382016-11-23 16:03:33 +020057 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: |
disf0924fb2016-12-03 04:01:12 +020097 git clone https://github.com/Mirantis/mk-lab-salt-model.git /srv/salt/reclass;
98 cd /srv/salt/reclass;
99 git checkout master;
disc5298382016-11-23 16:03:33 +0200100 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
dis1bd460c2016-11-24 11:39:01 +0200141- description: Workaround set low max_heap_size for Cassandra
dis45ea5fd2016-11-24 11:24:11 +0200142 cmd: |
disf0924fb2016-12-03 04:01:12 +0200143 cat << 'EOF' >> /srv/salt/reclass/classes/system/opencontrail/control/cluster.yml
dis45ea5fd2016-11-24 11:24:11 +0200144 # 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
disfdaa0c92016-12-06 21:50:19 +0200154- 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
disc5298382016-11-23 16:03:33 +0200168# Prepare salt services and nodes settings
169- description: Run 'linux' formula on cfg01
disf0924fb2016-12-03 04:01:12 +0200170 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
171 -C 'I@salt:master' state.sls linux
disc5298382016-11-23 16:03:33 +0200172 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
disf0924fb2016-12-03 04:01:12 +0200177 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
disfdaa0c92016-12-06 21:50:19 +0200181 yes/' /etc/ssh/sshd_config && service ssh restart";
disc5298382016-11-23 16:03:33 +0200182 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'
disf0924fb2016-12-03 04:01:12 +0200187 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
188 '*' cmd.run "echo ' StrictHostKeyChecking no' >> /root/.ssh/config"
disc5298382016-11-23 16:03:33 +0200189 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
disfdaa0c92016-12-06 21:50:19 +0200194 cmd: timeout 120 salt --hard-crash --state-output=mixed --state-verbose=False
disf0924fb2016-12-03 04:01:12 +0200195 -C 'I@salt:master' state.sls salt.master
disc5298382016-11-23 16:03:33 +0200196 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
disf0924fb2016-12-03 04:01:12 +0200207 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
208 -C 'I@salt:master' state.sls reclass
disc5298382016-11-23 16:03:33 +0200209 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
disf0924fb2016-12-03 04:01:12 +0200219- 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
disc5298382016-11-23 16:03:33 +0200226# Bootstrap all nodes
disf0924fb2016-12-03 04:01:12 +0200227
228- description: Configure linux on all nodes
disc5298382016-11-23 16:03:33 +0200229 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
disf0924fb2016-12-03 04:01:12 +0200235- description: Configure openssh on all nodes
disc5298382016-11-23 16:03:33 +0200236 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
disc5298382016-11-23 16:03:33 +0200244- 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
disfdaa0c92016-12-06 21:50:19 +0200251- description: Configure salt.minion on controllers
252 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls
253 salt.minion
disc5298382016-11-23 16:03:33 +0200254 node_name: cfg01.mk22-qa-lab01.local
255 retry: {count: 3, delay: 5}
256 skip_fail: false
257
disfdaa0c92016-12-06 21:50:19 +0200258- description: Check salt minion versions on slaves
259 cmd: salt '*' test.version
disc5298382016-11-23 16:03:33 +0200260 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
disf0924fb2016-12-03 04:01:12 +0200270