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