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