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