blob: a9b14344ec32a36632a7756bb8d47148626f1c19 [file] [log] [blame]
Dennis Dmitriev2a13a132016-11-04 00:56:23 +02001# Install salt to the config node
2- description: Configure tcpcloud repository on the cfg01 node
Dennis Dmitriev948c1182016-11-10 19:43:55 +02003 cmd: echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ xenial main security tcp tcp-salt' > /etc/apt/sources.list;
Dennis Dmitriev2a13a132016-11-04 00:56:23 +02004 echo 'deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty tcp-salt' >> /etc/apt/sources.list;
Dennis Dmitriev948c1182016-11-10 19:43:55 +02005 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 -;
Dennis Dmitriev2a13a132016-11-04 00:56:23 +02008 node_name: cfg01.mk22-lab-basic.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-lab-basic.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-lab-basic.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-lab-basic.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-lab-basic.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-lab-basic.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-lab-basic.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-lab-basic.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-lab-basic.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-lab-basic.local
111 master: localhost
112 EOF
113 node_name: cfg01.mk22-lab-basic.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-lab-basic.local;
123 node_name: cfg01.mk22-lab-basic.local
124 retry: {count: 3, delay: 10}
125 skip_fail: false
126
127
128# Prepare salt services and nodes settings
129- description: Run 'linux' formula on cfg01
130 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls
131 linux
132 node_name: cfg01.mk22-lab-basic.local
133 retry: {count: 3, delay: 5}
134 skip_fail: false
135
136- description: Run 'openssh' formula on cfg01
137 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls
138 openssh;sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
139 && service ssh restart
140 node_name: cfg01.mk22-lab-basic.local
141 retry: {count: 3, delay: 5}
142 skip_fail: false
143
144- description: '*Workaround* of the bug https://mirantis.jira.com/browse/PROD-7962'
145 cmd: echo ' StrictHostKeyChecking no' >> /root/.ssh/config
146 node_name: cfg01.mk22-lab-basic.local
147 retry: {count: 1, delay: 1}
148 skip_fail: false
149
150- description: Run 'salt' formula on cfg01
151 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls
152 salt
153 node_name: cfg01.mk22-lab-basic.local
154 retry: {count: 3, delay: 5}
155 skip_fail: true
156
157- description: Accept salt keys from all the nodes
158 cmd: salt-key -A -y
159 node_name: cfg01.mk22-lab-basic.local
160 retry: {count: 1, delay: 5}
161 skip_fail: false
162
163- description: Generate inventory for all the nodes to the /srv/salt/reclass/nodes/_generated
164 cmd: salt-call --hard-crash --state-output=mixed --state-verbose=False state.sls
165 reclass.storage
166 node_name: cfg01.mk22-lab-basic.local
167 retry: {count: 3, delay: 5}
168 skip_fail: false
169
170- description: Refresh pillars on all minions
171 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar
172 node_name: cfg01.mk22-lab-basic.local
173 retry: {count: 3, delay: 5}
174 skip_fail: false
175
176# Bootstrap all nodes
177- description: Configure linux on controllers
178 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls
179 linux
180 node_name: cfg01.mk22-lab-basic.local
181 retry: {count: 5, delay: 5}
182 skip_fail: false
183
184- description: Configure openssh on controllers
185 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C '* and not
186 cfg*' state.sls openssh;salt --hard-crash --state-output=mixed --state-verbose=False
187 -C '* and not cfg*' cmd.run "sed -i 's/PasswordAuthentication no/PasswordAuthentication
188 yes/' /etc/ssh/sshd_config && service ssh restart"
189 node_name: cfg01.mk22-lab-basic.local
190 retry: {count: 3, delay: 5}
191 skip_fail: false
192
193- description: '*Workaround* for the bug https://mirantis.jira.com/browse/PROD-8025'
194 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'apt-get
195 update && apt-get -y upgrade'
196 node_name: cfg01.mk22-lab-basic.local
197 retry: {count: 3, delay: 5}
Dennis Dmitriev948c1182016-11-10 19:43:55 +0200198 skip_fail: true
Dennis Dmitriev2a13a132016-11-04 00:56:23 +0200199
200- description: '*Workaround* for the bug https://mirantis.jira.com/browse/PROD-8021'
201 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'apt-get
202 -y install linux-image-extra-$(uname -r)'
203 node_name: cfg01.mk22-lab-basic.local
204 retry: {count: 3, delay: 5}
205 skip_fail: false
206
207- description: '*Workaround* for the bug https://mirantis.jira.com/browse/PROD-8025'
208 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'apt-get
209 -y install python-requests'
210 node_name: cfg01.mk22-lab-basic.local
211 retry: {count: 3, delay: 5}
212 skip_fail: false
213
214#- description: '*Workaround* of the bug https://mirantis.jira.com/browse/PROD-8063'
215# cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' cmd.run 'dhclient
216# -r;dhclient'
217# node_name: cfg01.mk22-lab-basic.local
218# retry: {count: 1, delay: 1}
219# skip_fail: false
220
221- description: Configure salt.minion on controllers
222 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls
223 salt.minion
224 node_name: cfg01.mk22-lab-basic.local
225 retry: {count: 3, delay: 5}
226 skip_fail: false
227
228- description: Configure ntp on controllers
229 cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' state.sls
230 ntp
231 node_name: cfg01.mk22-lab-basic.local
232 retry: {count: 5, delay: 10}
233 skip_fail: false