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