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