Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 1 | package com.mirantis.mk |
| 2 | /** |
| 3 | * Orchestration functions |
| 4 | * |
| 5 | */ |
| 6 | |
| 7 | def validateFoundationInfra(master) { |
| 8 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 9 | |
| 10 | salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['salt-key'], null, true) |
| 11 | salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version', [], null, true) |
| 12 | salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true) |
| 13 | salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory', [], null, true) |
| 14 | salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top', [], null, true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | |
| 18 | def installFoundationInfra(master) { |
| 19 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 20 | |
| 21 | salt.enforceState(master, 'I@salt:master', ['salt.master', 'reclass'], true) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 22 | |
| 23 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true) |
| 24 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
| 25 | |
| 26 | salt.enforceState(master, 'I@salt:master', ['linux.system'], true) |
| 27 | salt.enforceState(master, 'I@salt:master', ['salt.minion'], true) |
| 28 | |
Jakub Josef | 200550f | 2017-05-16 17:39:55 +0200 | [diff] [blame] | 29 | salt.enforceState(master, '*', ['linux.system'], true) |
| 30 | salt.enforceState(master, '*', ['salt.minion'], true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 31 | salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 32 | } |
| 33 | |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 34 | def installInfraKvm(master) { |
| 35 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 36 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 37 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true) |
| 38 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true) |
| 39 | |
| 40 | salt.enforceState(master, 'I@salt:control', ['salt.minion', 'linux.system', 'linux.network', 'ntp'], true) |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 41 | salt.enforceState(master, 'I@salt:control', 'libvirt', true) |
| 42 | salt.enforceState(master, 'I@salt:control', 'salt.control', true) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 43 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 44 | sleep(600) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 45 | |
Marek Celoud | c9b3cc8 | 2017-05-22 12:50:53 +0000 | [diff] [blame] | 46 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true) |
| 47 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true) |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 48 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 49 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 50 | def installOpenstackInfra(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 51 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 52 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 53 | // Install glusterfs |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 54 | salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 55 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 56 | // Install keepaliveds |
| 57 | //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1) |
| 58 | salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true) |
| 59 | salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true) |
| 60 | |
| 61 | // Check the keepalived VIPs |
| 62 | salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2']) |
| 63 | |
Alexander Noskov | 93acac4 | 2017-06-20 17:55:55 +0200 | [diff] [blame] | 64 | withEnv(['ASK_ON_ERROR=false']){ |
| 65 | retry(5) { |
| 66 | salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true) |
| 67 | } |
| 68 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 69 | |
| 70 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true) |
| 71 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 72 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 73 | // Install rabbitmq |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 74 | withEnv(['ASK_ON_ERROR=false']){ |
| 75 | retry(2) { |
| 76 | salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true) |
| 77 | } |
| 78 | } |
| 79 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 80 | // Check the rabbitmq status |
| 81 | salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 82 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 83 | // Install galera |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 84 | withEnv(['ASK_ON_ERROR=false']){ |
| 85 | retry(2) { |
| 86 | salt.enforceState(master, 'I@galera:master', 'galera', true) |
| 87 | } |
| 88 | } |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 89 | salt.enforceState(master, 'I@galera:slave', 'galera', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 90 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 91 | // Check galera status |
| 92 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 93 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 94 | |
| 95 | // // Setup mysql client |
| 96 | // salt.enforceState(master, 'I@mysql:client', 'mysql.client', true) |
| 97 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 98 | // Install haproxy |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 99 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 100 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 101 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 102 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 103 | // Install memcached |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 104 | salt.enforceState(master, 'I@memcached:server', 'memcached', true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 108 | def installOpenstackControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 109 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 110 | |
| 111 | // Install horizon dashboard |
| 112 | salt.enforceState(master, 'I@horizon:server', 'horizon', true) |
| 113 | salt.enforceState(master, 'I@nginx:server', 'nginx', true) |
| 114 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 115 | // setup keystone service |
| 116 | //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 117 | salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true) |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 118 | salt.enforceState(master, 'I@keystone:server', 'keystone.server', true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 119 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 120 | |
| 121 | // keystone:client must be called locally |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 122 | //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| 123 | salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2']) |
| 124 | sleep(30) |
| 125 | salt.enforceState(master, 'I@keystone:client', 'keystone.client', true) |
| 126 | salt.enforceState(master, 'I@keystone:client', 'keystone.client', true) |
| 127 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true) |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 128 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 129 | // Install glance and ensure glusterfs clusters |
| 130 | //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 131 | salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true) |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 132 | salt.enforceState(master, 'I@glance:server', 'glance.server', true) |
| 133 | salt.enforceState(master, 'I@glance:server', 'glusterfs.client', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 134 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 135 | // Update fernet tokens before doing request on keystone server |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 136 | salt.enforceState(master, 'I@keystone:server', 'keystone.server', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 137 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 138 | // Check glance service |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 139 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true) |
| 140 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 141 | // Install and check nova service |
| 142 | //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 143 | salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true) |
| 144 | salt.enforceState(master, 'I@nova:controller', 'nova.controller', true) |
| 145 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true) |
| 146 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 147 | // Install and check cinder service |
| 148 | //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 149 | salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true) |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 150 | salt.enforceState(master, 'I@cinder:controller', 'cinder', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 151 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true) |
| 152 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 153 | // Install neutron service |
| 154 | //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 155 | |
| 156 | salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true) |
| 157 | salt.enforceState(master, 'I@neutron:server', 'neutron.server', true) |
| 158 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true) |
| 159 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 160 | // Install heat service |
| 161 | //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 162 | salt.enforceState(master, 'I@heat:server and *01*', 'heat', true) |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 163 | salt.enforceState(master, 'I@heat:server', 'heat', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 164 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true) |
| 165 | |
| 166 | // Restart nova api |
| 167 | salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 171 | def installOpenstackNetwork(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 172 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 173 | |
| 174 | salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true) |
| 175 | } |
| 176 | |
| 177 | |
| 178 | def installOpenstackCompute(master) { |
| 179 | def salt = new com.mirantis.mk.Salt() |
| 180 | |
| 181 | // Configure compute nodes |
| 182 | retry(2) { |
Marek Celoud | e305ec7 | 2017-05-16 11:27:53 +0200 | [diff] [blame] | 183 | salt.runSaltProcessStep(master, 'I@nova:compute', 'state.highstate', ['exclude=opencontrail.client'], null, true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | |
| 187 | |
| 188 | def installContrailNetwork(master) { |
| 189 | def salt = new com.mirantis.mk.Salt() |
| 190 | |
| 191 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 192 | // Install opencontrail database services |
| 193 | //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 194 | try { |
| 195 | salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true) |
| 196 | } catch (Exception e) { |
| 197 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*') |
| 198 | } |
| 199 | |
| 200 | try { |
| 201 | salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true) |
| 202 | } catch (Exception e) { |
| 203 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database') |
| 204 | } |
| 205 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 206 | // Install opencontrail control services |
| 207 | //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 208 | salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 209 | salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 210 | salt.runSaltProcessStep(master, 'I@opencontrail:collector', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 211 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 212 | // Test opencontrail |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 213 | salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 217 | def installContrailCompute(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 218 | def salt = new com.mirantis.mk.Salt() |
| 219 | // Configure compute nodes |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 220 | // Provision opencontrail control services |
| 221 | salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 222 | // Provision opencontrail virtual routers |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 223 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 224 | salt.runSaltProcessStep(master, 'I@nova:compute', 'cmd.run', ['exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || sleep 5 && reboot & "'], null, true) |
| 225 | sleep(300) |
Marek Celoud | e305ec7 | 2017-05-16 11:27:53 +0200 | [diff] [blame] | 226 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 230 | def installKubernetesInfra(master) { |
Tomáš Kukrál | 0ea82db | 2017-05-02 11:16:05 +0200 | [diff] [blame] | 231 | def common = new com.mirantis.mk.Common() |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 232 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 233 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 234 | // Install glusterfs |
Tomáš Kukrál | 0ea82db | 2017-05-02 11:16:05 +0200 | [diff] [blame] | 235 | if (common.checkContains('INSTALL', 'glusterfs')) { |
| 236 | salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service') |
| 237 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 238 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 239 | // Install keepalived |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 240 | salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived') |
| 241 | salt.enforceState(master, 'I@keepalived:cluster', 'keepalived') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 242 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 243 | // Setup glusterfs |
Tomáš Kukrál | 0ea82db | 2017-05-02 11:16:05 +0200 | [diff] [blame] | 244 | if (common.checkContains('INSTALL', 'glusterfs')) { |
Alexander Noskov | 93acac4 | 2017-06-20 17:55:55 +0200 | [diff] [blame] | 245 | withEnv(['ASK_ON_ERROR=false']){ |
| 246 | retry(5) { |
| 247 | salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup') |
| 248 | } |
| 249 | } |
Tomáš Kukrál | 0ea82db | 2017-05-02 11:16:05 +0200 | [diff] [blame] | 250 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status']) |
| 251 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status']) |
| 252 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 253 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 254 | // Install haproxy |
Tomáš Kukrál | 7c99e32 | 2017-05-02 11:31:31 +0200 | [diff] [blame] | 255 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 256 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 257 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 258 | // Install docker |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 259 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 260 | salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 261 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 262 | // Install etcd |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 263 | salt.enforceState(master, 'I@etcd:server', 'etcd.server.service') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 264 | salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health']) |
| 265 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | |
Tomáš Kukrál | c1a1bbc | 2017-04-28 21:16:25 +0200 | [diff] [blame] | 269 | def installKubernetesControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 270 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 271 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 272 | // Install Kubernetes pool and Calico |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 273 | salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons') |
| 274 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 275 | |
| 276 | // Setup etcd server |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 277 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 278 | |
| 279 | // Run k8s without master.setup |
| 280 | salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup']) |
| 281 | |
| 282 | // Run k8s master setup |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 283 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 284 | |
| 285 | // Restart kubelet |
| 286 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
| 287 | } |
| 288 | |
| 289 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 290 | def installKubernetesCompute(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 291 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 292 | |
| 293 | // Refresh minion's pillar data |
| 294 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true) |
| 295 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
| 296 | |
| 297 | // Bootstrap all nodes |
| 298 | salt.enforceState(master, 'I@kubernetes:pool', 'linux') |
| 299 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion') |
| 300 | salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp']) |
| 301 | |
| 302 | // Create and distribute SSL certificates for services using salt state |
| 303 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert') |
| 304 | |
| 305 | // Install docker |
| 306 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
| 307 | |
| 308 | // Install Kubernetes and Calico |
| 309 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
| 310 | |
| 311 | } |
| 312 | |
| 313 | |
| 314 | def installKubernetesContrailCompute(master) { |
| 315 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 316 | // Install opencontrail |
| 317 | salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail']) |
| 318 | // Reboot compute nodes |
| 319 | salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot') |
| 320 | } |
| 321 | |
| 322 | |
| 323 | def installStacklightControl(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 324 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 325 | |
| 326 | // infra install |
| 327 | // Install the StackLight backends |
| 328 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true) |
| 329 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true) |
| 330 | |
| 331 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true) |
| 332 | salt.enforceState(master, 'I@influxdb:server', 'influxdb', true) |
| 333 | |
| 334 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true) |
| 335 | salt.enforceState(master, 'I@kibana:server', 'kibana.server', true) |
| 336 | |
| 337 | salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true) |
| 338 | salt.enforceState(master, 'I@grafana:server','grafana.server', true) |
| 339 | |
| 340 | salt.enforceState(master, 'I@nagios:server', 'nagios.server', true) |
| 341 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true) |
Marek Celoud | ebc623b | 2017-06-02 17:12:31 +0200 | [diff] [blame] | 342 | salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 343 | |
| 344 | sleep(10) |
| 345 | } |
| 346 | |
| 347 | def installStacklightClient(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 348 | def salt = new com.mirantis.mk.Salt() |
| 349 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 350 | |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 351 | salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'cmd.run', ['salt-call state.sls elasticsearch.client'], null, true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 352 | // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 353 | salt.runSaltProcessStep(master, 'I@kibana:client', 'cmd.run', ['salt-call state.sls kibana.client'], null, true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 354 | // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
| 355 | |
| 356 | // Install collectd, heka and sensu services on the nodes, this will also |
| 357 | // generate the metadata that goes into the grains and eventually into Salt Mine |
| 358 | salt.enforceState(master, '*', 'collectd', true) |
| 359 | salt.enforceState(master, '*', 'salt.minion', true) |
| 360 | salt.enforceState(master, '*', 'heka', true) |
| 361 | |
| 362 | // Gather the Grafana metadata as grains |
| 363 | salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true) |
| 364 | |
| 365 | // Update Salt Mine |
| 366 | salt.enforceState(master, '*', 'salt.minion.grains', true) |
| 367 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true) |
| 368 | salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true) |
| 369 | |
| 370 | sleep(5) |
| 371 | |
| 372 | // Update Heka |
| 373 | salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true) |
| 374 | |
| 375 | // Update collectd |
| 376 | salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true) |
| 377 | |
| 378 | // Update Nagios |
| 379 | salt.enforceState(master, 'I@nagios:server', 'nagios', true) |
| 380 | // Stop the Nagios service because the package starts it by default and it will |
| 381 | // started later only on the node holding the VIP address |
| 382 | salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true) |
| 383 | |
| 384 | // Update Sensu |
| 385 | // TODO for stacklight team, should be fixed in model |
| 386 | //salt.enforceState(master, 'I@sensu:server', 'sensu', true) |
| 387 | |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 388 | salt.runSaltProcessStep(master, 'I@grafana:client and *01*', 'cmd.run', ['salt-call state.sls grafana.client'], null, true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 389 | // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 390 | |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 391 | // Finalize the configuration of Grafana (add the dashboards...) |
Alexander Noskov | 8448fc5 | 2017-06-21 14:03:45 +0200 | [diff] [blame] | 392 | salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 393 | salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true) |
| 394 | salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true) |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 395 | // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
| 396 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 397 | // Get the StackLight monitoring VIP addres |
| 398 | //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 399 | //vip=${vip:=172.16.10.253} |
| 400 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Jakub Josef | bceaa32 | 2017-06-13 18:28:27 +0200 | [diff] [blame] | 401 | common.prettyPrint(pillar) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 402 | def stacklight_vip = pillar['return'][0].values()[0] |
| 403 | |
| 404 | if (stacklight_vip) { |
| 405 | // (re)Start manually the services that are bound to the monitoring VIP |
| 406 | common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
| 407 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true) |
| 408 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true) |
| 409 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true) |
| 410 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true) |
| 411 | } else { |
| 412 | throw new Exception("Missing stacklight_vip") |
| 413 | } |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 414 | } |