blob: ed366b8f294a92c82faed081433cf716d0110886 [file] [log] [blame]
Jiri Broulikbb447ac2017-05-04 15:36:22 +02001/**
2 * Update packages on given nodes
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [http://10.10.10.1:8000].
7 *
8**/
9
10def common = new com.mirantis.mk.Common()
11def salt = new com.mirantis.mk.Salt()
12
13
14def saltMaster
15
16timestamps {
17 node() {
18
19 stage('Connect to Salt API') {
20 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
21 }
22
23 state('Prepare upgrade') {
24 // #ignorovat no response a chyby - nene, chyby opravíme
25
26 // read domain variable
27 def _pillar = salt.getPillar(master, 'ctl01*', '_param:cluster_domain')
28 def domain = _pillar['return'][0].values()[0]
29
30 // # test sync db
31 // salt 'kvm02*' cmd.run 'virsh destroy upg01.${domain}'
32 salt.runSaltProcessStep(saltMaster, 'kvm02*', 'cmd.run', "virsh destroy upg01.${domain}", [], null, true)
33
34 // salt 'kvm02*' cmd.run 'virsh undefine upg01.${domain}'
35 salt.runSaltProcessStep(saltMaster, 'kvm02*', 'cmd.run', "virsh undefine upg01.${domain}", [], null, true)
36
37 // salt-key -d upg01.${domain} -y
38 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', "salt-key -d upg01.${domain} -y", [], null, true)
39 // salt 'kvm02*' state.sls salt.control
40 salt.enforceState(saltMaster, 'kvm02*', 'salt.control')
41
42 sleep(60)
43
44 // salt '*' saltutil.refresh_pillar
45 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
46 // salt '*' saltutil.sync_all
47 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
48
49 // salt "upg*" state.sls linux,openssh,salt.minion,ntp,rsyslog
50 salt.enforceState(master, 'upg*', ['linux', 'openssh', 'salt.minion', 'ntp', 'rsyslog'])
51 // salt '*' state.apply salt.minion.grains
52 salt.enforceState(master, '*', 'salt.minion.grains')
53 // salt "upg*" state.sls linux,openssh,salt.minion,ntp,rsyslog
54 salt.enforceState(master, 'upg*', ['linux', 'openssh', 'salt.minion', 'ntp', 'rsyslog'])
55
56 // read backupninja variable
57 def _pillar = salt.getPillar(master, 'I@backupninja:server', '_param:single_address')
58 def backupninja_backup_host = _pillar['return'][0].values()[0]
59
60 // salt "upg*" state.sls rabbitmq
61 salt.enforceState(master, 'upg*', 'rabbitmq')
62 // salt "upg*" state.sls memcached
63 salt.enforceState(master, 'upg*', 'memcached')
64 // salt -C 'I@backupninja:server' state.sls backupninja
65 salt.enforceState(master, 'I@backupninja:server', 'backupninja')
66 // salt -C 'I@backupninja:client' state.sls backupninja
67 salt.enforceState(master, 'I@backupninja:client', 'backupninja')
68 // salt -C 'I@backupninja:client' cmd.run 'ssh-keygen -f "/root/.ssh/known_hosts" -R ${backupninja_backup_host}'
69 salt.runSaltProcessStep(master, 'I@backupninja:client', 'cmd.run', "ssh-keygen -f /root/.ssh/known_hosts -R ${backupninja_backup_host}", [], null, true)
70 // salt -C 'I@backupninja:client' cmd.run 'ssh-keyscan -H ${backupninja_backup_host} >> /root/.ssh/known_hosts'
71 salt.runSaltProcessStep(master, 'I@backupninja:client', 'cmd.run', "ssh-keyscan -H ${backupninja_backup_host} >> /root/.ssh/known_hosts", [], null, true)
72 // salt -C 'I@backupninja:client' cmd.run 'backupninja -n --run /etc/backup.d/101.mysql'
73 salt.runSaltProcessStep(master, 'I@backupninja:client', 'cmd.run', "backupninja -n --run /etc/backup.d/101.mysql", [], null, true)
74 // salt -C 'I@backupninja:client' cmd.run 'backupninja -n --run /etc/backup.d/200.backup.rsync'
75 salt.runSaltProcessStep(master, 'I@backupninja:client', 'cmd.run', "backupninja -n --run /etc/backup.d/200.backup.rsync", [], null, true)
76 // salt -C 'I@mysql:client' state.sls mysql.client
77 salt.enforceState(master, 'I@mysql:client', 'mysql.client')
78
79 // salt "upg*" state.sls keystone.server
80 // salt "upg*" state.sls keystone.client.service
81 salt.enforceState(master, 'upg*', ['keystone.server', 'keystone.client.service'])
82 // salt 'upg*' state.sls glance
83 // salt "upg*" state.sls keystone.server
84 // salt 'upg*' state.sls nova
85 // salt 'upg*' state.sls cinder
86 // salt 'upg*' state.sls neutron
87 // salt 'upg*' state.sls heat
88 salt.enforceState(master, 'upg*', ['glance', 'keystone.server', 'nova', 'cinder', 'neutron', 'heat'])
89
90 // salt 'upg01*' cmd.run ". /root/keystonercv3; openstack service list"
91 // salt 'upg01*' cmd.run ". /root/keystonercv3; openstack image list"
92 // salt 'upg01*' cmd.run ". /root/keystonercv3; openstack flavor list"
93 // salt 'upg01*' cmd.run ". /root/keystonercv3; openstack compute service list"
94 // salt 'upg01*' cmd.run ". /root/keystonercv3; openstack server list"
95 // salt 'upg01*' cmd.run ". /root/keystonercv3; openstack network list"
96 // salt 'upg01*' cmd.run ". /root/keystonercv3; openstack orchestration service list"
97 salt.runSaltProcessStep(master, 'upg01*', 'cmd.run', '. /root/keystonercv3; openstack service list; openstack image list; openstack flavor list; openstack compute service list; openstack server list; openstack network list; openstack orchestration service list', null, true)
98 }
99
100 stage('Ask for manual confirmation') {
101 input message: "Do you want to continue with update?"
102 }
103
104 state('Start upgrade') {
105 // # actual upgrade
106 // salt 'kvm01*' cmd.run 'virsh destroy prx01.${domain}'
107 salt.runSaltProcessStep(master, 'kvm01*', 'cmd.run', "virsh destroy prx01.${domain}", null, true)
108 // salt 'kvm03*' cmd.run 'virsh destroy prx02.${domain}'
109 salt.runSaltProcessStep(master, 'kvm03*', 'cmd.run', "virsh destroy prx02.${domain}", null, true)
110 // salt 'kvm01*' cmd.run 'virsh destroy ctl01.${domain}'
111 salt.runSaltProcessStep(master, 'kvm01*', 'cmd.run', "virsh destroy ctl01.${domain}", null, true)
112 // salt 'kvm02*' cmd.run 'virsh destroy ctl02.${domain}'
113 salt.runSaltProcessStep(master, 'kvm02*', 'cmd.run', "virsh destroy ctl02.${domain}", null, true)
114 // salt 'kvm03*' cmd.run 'virsh destroy ctl03.${domain}'
115 salt.runSaltProcessStep(master, 'kvm03*', 'cmd.run', "virsh destroy ctl03.${domain}", null, true)
116
117 // salt 'kvm01*' cmd.run '[ ! -f ./prx01.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/prx01.${domain}/system.qcow2 ./prx01.${domain}.qcow2.bak'
118 salt.runSaltProcessStep(master, 'kvm01*', 'cmd.run', "[ ! -f ./prx01.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/prx01.${domain}/system.qcow2 ./prx01.${domain}.qcow2.bak", null, true)
119 // salt 'kvm03*' cmd.run '[ ! -f ./prx02.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/prx02.${domain}/system.qcow2 ./prx02.${domain}.qcow2.bak'
120 salt.runSaltProcessStep(master, 'kvm03*', 'cmd.run', "[ ! -f ./prx02.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/prx02.${domain}/system.qcow2 ./prx02.${domain}.qcow2.bak", null, true)
121 // salt 'kvm01*' cmd.run '[ ! -f ./ctl01.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/ctl01.${domain}/system.qcow2 ./ctl01.${domain}.qcow2.bak'
122 salt.runSaltProcessStep(master, 'kvm01*', 'cmd.run', "[ ! -f ./ctl01.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/ctl01.${domain}/system.qcow2 ./ctl01.${domain}.qcow2.bak", null, true)
123 // salt 'kvm02*' cmd.run '[ ! -f ./ctl02.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/ctl02.${domain}/system.qcow2 ./ctl02.${domain}.qcow2.bak'
124 salt.runSaltProcessStep(master, 'kvm02*', 'cmd.run', "[ ! -f ./ctl02.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/ctl02.${domain}/system.qcow2 ./ctl02.${domain}.qcow2.bak", null, true)
125 // salt 'kvm03*' cmd.run '[ ! -f ./ctl03.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/ctl03.${domain}/system.qcow2 ./ctl03.${domain}.qcow2.bak'
126 salt.runSaltProcessStep(master, 'kvm03*', 'cmd.run', "[ ! -f ./ctl03.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/ctl03.${domain}/system.qcow2 ./ctl03.${domain}.qcow2.bak", null, true)
127
128 // salt 'kvm01*' cmd.run 'virsh undefine prx01.${domain}'
129 salt.runSaltProcessStep(master, 'kvm01*', 'cmd.run', "virsh undefine prx01.${domain}", null, true)
130 // salt 'kvm03*' cmd.run 'virsh undefine prx02.${domain}'
131 salt.runSaltProcessStep(master, 'kvm03*', 'cmd.run', "virsh undefine prx02.${domain}", null, true)
132 // salt 'kvm01*' cmd.run 'virsh undefine ctl01.${domain}'
133 salt.runSaltProcessStep(master, 'kvm01*', 'cmd.run', "virsh undefine ctl01.${domain}", null, true)
134 // salt 'kvm02*' cmd.run 'virsh undefine ctl02.${domain}'
135 salt.runSaltProcessStep(master, 'kvm02*', 'cmd.run', "virsh undefine ctl02.${domain}", null, true)
136 // salt 'kvm03*' cmd.run 'virsh undefine ctl03.${domain}'
137 salt.runSaltProcessStep(master, 'kvm03*', 'cmd.run', "virsh undefine ctl03.${domain}", null, true)
138
139 // salt-key -d ctl01.${domain} -y
140 // salt-key -d ctl02.${domain} -y
141 // salt-key -d ctl03.${domain} -y
142 // salt-key -d prx01.${domain} -y
143 // salt-key -d prx02.${domain} -y
144 salt.runSaltProcessStep(master, 'I@salt', 'cmd.run', "salt-key -d ctl01.${domain},ctl01.${domain},ctl03.${domain},prx01.${domain},prx02.${domain}", null, true)
145
146 // salt 'kvm*' state.sls salt.control
147 salt.enforceState(master, 'kvm*', 'salt.control')
148
149 sleep(60)
150
151 // salt '*' saltutil.refresh_pillar
152 salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true)
153 // salt '*' saltutil.sync_all
154 salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true)
155
156 // salt "ctl*" state.sls linux,openssh,salt.minion,ntp,rsyslog
157 // salt 'prx*' state.sls linux,openssh,salt.minion,ntp,rsyslog
158 // salt "ctl*" state.sls linux,openssh,salt.minion,ntp,rsyslog
159 salt.enforceState(master, 'ctl* or prx* or ctl*', ['linux', 'openssh', 'salt.minion', 'ntp', 'rsyslog'])
160 // salt 'ctl*' state.sls keepalived
161 // salt 'ctl*' state.sls haproxy
162 salt.enforceState(master, 'ctl*', ['keepalived', 'haproxy'])
163 // salt 'ctl*' service.restart rsyslog
164 salt.runSaltProcessStep(master, 'ctl*', 'service.restart', ['rsyslog'], null, true)
165 // salt "ctl*" state.sls memcached
166 // salt "ctl*" state.sls keystone.server
167 salt.enforceState(master, 'ctl*', ['memcached', 'keystone.server'])
168 // salt 'ctl01*' state.sls keystone.client
169 salt.enforceState(master, 'ctl01*', ['keystone.client'])
170 // salt 'ctl*' state.sls glance
171 salt.enforceState(master, 'ctl*', 'glance')
172 // salt 'ctl*' state.sls glusterfs.client
173 salt.enforceState(master, 'ctl*', 'glusterfs.client')
174 // salt 'ctl*' state.sls keystone.server
175 salt.enforceState(master, 'ctl*', 'keystone.server')
176 // salt 'ctl*' state.sls nova
177 salt.enforceState(master, 'ctl*', 'nova')
178 // salt 'ctl*' state.sls cinder
179 salt.enforceState(master, 'ctl*', 'cinder')
180 // salt 'ctl*' state.sls neutron
181 salt.enforceState(master, 'ctl*', 'neutron')
182 // salt 'ctl*' state.sls heat
183 salt.enforceState(master, 'ctl*', 'heat')
184
185 // salt 'cmp*' cmd.run 'service nova-compute restart'
186 salt.runSaltProcessStep(master, 'cmp*', 'service.restart', ['nova-compute'], null, true)
187
188 // salt 'prx*' state.sls linux,openssh,salt.minion,ntp,rsyslog - TODO: proč? už to jednou projelo
189 // salt 'ctl*' state.sls keepalived
190 // salt 'prx*' state.sls keepalived
191 salt.enforceState(master, 'prx*', 'keepalived')
192 // salt 'prx*' state.sls horizon
193 salt.enforceState(master, 'prx*', 'horizon')
194 // salt 'prx*' state.sls nginx
195 salt.enforceState(master, 'prx*', 'nginx')
196
197 // salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack service list"
198 // salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack image list"
199 // salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack flavor list"
200 // salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack compute service list"
201 // salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack server list"
202 // salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack network list"
203 // salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack orchestration service list"
204 salt.runSaltProcessStep(master, 'upg01*', 'cmd.run', '. /root/keystonercv3; openstack service list; openstack image list; openstack flavor list; openstack compute service list; openstack server list; openstack network list; openstack orchestration service list', null, true)
205 }
206
207 }
208}