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