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