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 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 17 | def installFoundationInfra(master) { |
| 18 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 19 | |
Vasyl Saienko | e36ab7c | 2017-07-17 14:35:48 +0300 | [diff] [blame] | 20 | salt.enforceState(master, 'I@salt:master', ['salt.master', 'reclass'], true, false, null, false, 60, 2) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 21 | |
| 22 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true) |
| 23 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
| 24 | |
| 25 | salt.enforceState(master, 'I@salt:master', ['linux.system'], true) |
Vasyl Saienko | e36ab7c | 2017-07-17 14:35:48 +0300 | [diff] [blame] | 26 | salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 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) |
Vasyl Saienko | e36ab7c | 2017-07-17 14:35:48 +0300 | [diff] [blame] | 30 | salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp'], true) |
Tomáš Kukrál | 7e767f9 | 2017-08-18 14:53:17 +0200 | [diff] [blame] | 31 | salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2) |
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 | |
Richard Felkl | 286f25f | 2017-07-26 14:23:55 +0200 | [diff] [blame] | 40 | salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2) |
Vasyl Saienko | e36ab7c | 2017-07-17 14:35:48 +0300 | [diff] [blame] | 41 | salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp'], true) |
Tomáš Kukrál | 0abdde5 | 2017-03-01 21:57:23 +0100 | [diff] [blame] | 42 | salt.enforceState(master, 'I@salt:control', 'libvirt', true) |
| 43 | salt.enforceState(master, 'I@salt:control', 'salt.control', true) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 44 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 45 | sleep(600) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 46 | |
Marek Celoud | c9b3cc8 | 2017-05-22 12:50:53 +0000 | [diff] [blame] | 47 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true) |
| 48 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true) |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 49 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 50 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 51 | def installInfra(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 52 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 53 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 54 | // Install glusterfs |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 55 | if (salt.testTarget(master, 'I@glusterfs:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 56 | salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 57 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 58 | withEnv(['ASK_ON_ERROR=false']){ |
| 59 | retry(5) { |
| 60 | salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true) |
| 61 | } |
Alexander Noskov | 93acac4 | 2017-06-20 17:55:55 +0200 | [diff] [blame] | 62 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 63 | |
| 64 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true) |
| 65 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true) |
Alexander Noskov | 93acac4 | 2017-06-20 17:55:55 +0200 | [diff] [blame] | 66 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 67 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 68 | // Install galera |
Richard Felkl | c0f163e | 2017-07-27 15:11:12 +0200 | [diff] [blame] | 69 | if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 70 | withEnv(['ASK_ON_ERROR=false']){ |
| 71 | retry(2) { |
| 72 | salt.enforceState(master, 'I@galera:master', 'galera', true) |
| 73 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 74 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 75 | salt.enforceState(master, 'I@galera:slave', 'galera', true) |
| 76 | |
| 77 | // Check galera status |
| 78 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 79 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 80 | // If galera is not enabled check if we need to install mysql:server |
| 81 | } else if (salt.testTarget(master, 'I@mysql:server')){ |
| 82 | salt.enforceState(master, 'I@mysql:server', 'mysql.server', true) |
| 83 | if (salt.testTarget(master, 'I@mysql:client')){ |
| 84 | salt.enforceState(master, 'I@mysql:client', 'mysql.client', true) |
| 85 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 86 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 87 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 88 | // Install docker |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 89 | if (salt.testTarget(master, 'I@docker:host')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 90 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
| 91 | salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps']) |
| 92 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 93 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 94 | // Install keepalived |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 95 | if (salt.testTarget(master, 'I@keepalived:cluster')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 96 | salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true) |
| 97 | salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true) |
| 98 | } |
| 99 | |
| 100 | // Install rabbitmq |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 101 | if (salt.testTarget(master, 'I@rabbitmq:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 102 | withEnv(['ASK_ON_ERROR=false']){ |
| 103 | retry(2) { |
| 104 | salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // Check the rabbitmq status |
| 109 | salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status']) |
| 110 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 111 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 112 | // Install haproxy |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 113 | if (salt.testTarget(master, 'I@haproxy:proxy')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 114 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true) |
| 115 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 116 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
| 117 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 118 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 119 | // Install memcached |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 120 | if (salt.testTarget(master, 'I@memcached:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 121 | salt.enforceState(master, 'I@memcached:server', 'memcached', true) |
| 122 | } |
| 123 | |
| 124 | // Install etcd |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 125 | if (salt.testTarget(master, 'I@etcd:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 126 | salt.enforceState(master, 'I@etcd:server', 'etcd.server.service') |
| 127 | salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['bash -c "source /var/lib/etcd/configenv && etcdctl cluster-health"']) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | def installOpenstackInfra(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 132 | def orchestrate = new com.mirantis.mk.Orchestrate() |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 133 | |
| 134 | // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 135 | orchestrate.installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 139 | def installOpenstackControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 140 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 141 | |
| 142 | // Install horizon dashboard |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 143 | if (salt.testTarget(master, 'I@horizon:server')) { |
| 144 | salt.enforceState(master, 'I@horizon:server', 'horizon', true) |
| 145 | } |
| 146 | if (salt.testTarget(master, 'I@nginx:server')) { |
| 147 | salt.enforceState(master, 'I@nginx:server', 'nginx', true) |
| 148 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 149 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 150 | // setup keystone service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 151 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 152 | //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1) |
| 153 | salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true) |
| 154 | salt.enforceState(master, 'I@keystone:server', 'keystone.server', true) |
| 155 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 156 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 157 | // keystone:client must be called locally |
| 158 | //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| 159 | salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2']) |
| 160 | sleep(30) |
| 161 | } |
| 162 | if (salt.testTarget(master, 'I@keystone:client')) { |
Vasyl Saienko | ff6f0f0 | 2017-07-19 15:54:16 +0300 | [diff] [blame] | 163 | salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client', true) |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 164 | salt.enforceState(master, 'I@keystone:client', 'keystone.client', true) |
| 165 | } |
| 166 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 167 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true) |
| 168 | } |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 169 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 170 | // Install glance and ensure glusterfs clusters |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 171 | if (salt.testTarget(master, 'I@glance:server')) { |
| 172 | //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
| 173 | salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true) |
| 174 | salt.enforceState(master, 'I@glance:server', 'glance.server', true) |
| 175 | } |
| 176 | if (salt.testTarget(master, 'I@glusterfs:client')) { |
| 177 | salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true) |
| 178 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 179 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 180 | // Update fernet tokens before doing request on keystone server |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 181 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 182 | salt.enforceState(master, 'I@keystone:server', 'keystone.server', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 183 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 184 | // Check glance service |
| 185 | if (salt.testTarget(master, 'I@glance:server')){ |
| 186 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true) |
| 187 | } |
| 188 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 189 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 190 | // Create glance resources |
| 191 | if (salt.testTarget(master, 'I@glance:client')) { |
| 192 | salt.enforceState(master, 'I@glance:client', 'glance.client', true) |
| 193 | } |
| 194 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 195 | // Install and check nova service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 196 | if (salt.testTarget(master, 'I@nova:controller')) { |
| 197 | //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1) |
| 198 | salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true) |
| 199 | salt.enforceState(master, 'I@nova:controller', 'nova.controller', true) |
| 200 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 201 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true) |
| 202 | } |
| 203 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 204 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 205 | // Create nova resources |
| 206 | if (salt.testTarget(master, 'I@nova:client')) { |
| 207 | salt.enforceState(master, 'I@nova:client', 'nova.client', true) |
| 208 | } |
| 209 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 210 | // Install and check cinder service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 211 | if (salt.testTarget(master, 'I@cinder:controller')) { |
| 212 | //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1) |
| 213 | salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true) |
| 214 | salt.enforceState(master, 'I@cinder:controller', 'cinder', true) |
| 215 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 216 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true) |
| 217 | } |
| 218 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 219 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 220 | // Install neutron service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 221 | if (salt.testTarget(master, 'I@neutron:server')) { |
| 222 | //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 223 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 224 | salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true) |
| 225 | salt.enforceState(master, 'I@neutron:server', 'neutron.server', true) |
| 226 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 227 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true) |
| 228 | } |
| 229 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 230 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 231 | // Create neutron resources |
| 232 | if (salt.testTarget(master, 'I@neutron:client')) { |
| 233 | salt.enforceState(master, 'I@neutron:client', 'neutron.client', true) |
| 234 | } |
| 235 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 236 | // Install heat service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 237 | if (salt.testTarget(master, 'I@heat:server')) { |
| 238 | //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1) |
| 239 | salt.enforceState(master, 'I@heat:server and *01*', 'heat', true) |
| 240 | salt.enforceState(master, 'I@heat:server', 'heat', true) |
| 241 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 242 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true) |
| 243 | } |
| 244 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 245 | |
| 246 | // Restart nova api |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 247 | if (salt.testTarget(master, 'I@nova:controller')) { |
| 248 | salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api']) |
| 249 | } |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 250 | |
| 251 | // Install ironic service |
| 252 | if (salt.testTarget(master, 'I@ironic:api')) { |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 253 | salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api', true) |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 254 | salt.enforceState(master, 'I@ironic:api', 'ironic.api', true) |
| 255 | } |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 256 | |
| 257 | // Install designate service |
| 258 | if (salt.testTarget(master, 'I@designate:server:enabled')) { |
| 259 | if (salt.testTarget(master, 'I@designate:server:backend:bind9')) { |
| 260 | salt.enforceState(master, 'I@bind:server', 'bind.server', true) |
| 261 | } |
| 262 | if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) { |
| 263 | salt.enforceState(master, 'I@powerdns:server', 'powerdns.server', true) |
| 264 | } |
| 265 | salt.enforceState(master, 'I@designate:server and *01*', 'designate.server', true) |
| 266 | salt.enforceState(master, 'I@designate:server', 'designate.server', true) |
| 267 | } |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 268 | |
| 269 | // Install octavia api service |
| 270 | if (salt.testTarget(master, 'I@octavia:api')) { |
| 271 | salt.enforceState(master, 'I@octavia:api', 'octavia', true) |
| 272 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 276 | def installIronicConductor(master){ |
| 277 | def salt = new com.mirantis.mk.Salt() |
| 278 | |
| 279 | if (salt.testTarget(master, 'I@ironic:conductor')) { |
| 280 | salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor', true) |
| 281 | salt.enforceState(master, 'I@ironic:conductor', 'apache', true) |
| 282 | } |
| 283 | if (salt.testTarget(master, 'I@tftpd_hpa:server')) { |
| 284 | salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa', true) |
| 285 | } |
| 286 | |
| 287 | if (salt.testTarget(master, 'I@nova:compute')) { |
| 288 | salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute']) |
| 289 | } |
| 290 | |
| 291 | if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) { |
| 292 | salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator', true) |
| 293 | } |
| 294 | if (salt.testTarget(master, 'I@ironic:client')) { |
| 295 | salt.enforceState(master, 'I@ironic:client', 'ironic.client', true) |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | |
| 300 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 301 | def installOpenstackNetwork(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 302 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 303 | |
| 304 | salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true) |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 305 | |
| 306 | // install octavia manager services |
| 307 | if (salt.testTarget(master, 'I@octavia:manager')) { |
| 308 | salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'], null, true) |
| 309 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca', true) |
| 310 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert', true) |
| 311 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | |
| 315 | def installOpenstackCompute(master) { |
| 316 | def salt = new com.mirantis.mk.Salt() |
| 317 | |
| 318 | // Configure compute nodes |
| 319 | retry(2) { |
Marek Celoud | e305ec7 | 2017-05-16 11:27:53 +0200 | [diff] [blame] | 320 | 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] | 321 | } |
| 322 | } |
| 323 | |
| 324 | |
| 325 | def installContrailNetwork(master) { |
Martin Polreich | fc9854c | 2017-06-30 11:17:36 +0200 | [diff] [blame] | 326 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 327 | def salt = new com.mirantis.mk.Salt() |
| 328 | |
| 329 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 330 | // Install opencontrail database services |
| 331 | //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 332 | try { |
| 333 | salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true) |
| 334 | } catch (Exception e) { |
| 335 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*') |
| 336 | } |
| 337 | |
| 338 | try { |
| 339 | salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true) |
| 340 | } catch (Exception e) { |
| 341 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database') |
| 342 | } |
| 343 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 344 | // Install opencontrail control services |
| 345 | //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 346 | salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 347 | salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 348 | 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] | 349 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 350 | // Test opencontrail |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 351 | salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 355 | def installContrailCompute(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 356 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 357 | // Configure compute nodes |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 358 | // Provision opencontrail control services |
| 359 | salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 360 | // Provision opencontrail virtual routers |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 361 | |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame^] | 362 | // Generate script /usr/lib/contrail/if-vhost0 for up vhost0 |
| 363 | try { |
| 364 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail', true) |
| 365 | } catch (Exception e) { |
| 366 | common.warningMsg('Exception in state opencontrail on I@opencontrail:compute') |
| 367 | } |
| 368 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 369 | 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) |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame^] | 370 | |
| 371 | if (salt.testTarget(master, 'I@opencontrail:compute')) { |
| 372 | sleep(300) |
| 373 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true) |
| 374 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail', true) |
| 375 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 379 | def installKubernetesInfra(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 380 | def orchestrate = new com.mirantis.mk.Orchestrate() |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 381 | // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 382 | orchestrate.installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | |
Tomáš Kukrál | c1a1bbc | 2017-04-28 21:16:25 +0200 | [diff] [blame] | 386 | def installKubernetesControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 387 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 388 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 389 | // Install Kubernetes pool and Calico |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 390 | salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons') |
| 391 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 392 | |
| 393 | // Setup etcd server |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 394 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 395 | |
| 396 | // Run k8s without master.setup |
| 397 | salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup']) |
| 398 | |
| 399 | // Run k8s master setup |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 400 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 401 | |
| 402 | // Restart kubelet |
| 403 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
| 404 | } |
| 405 | |
| 406 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 407 | def installKubernetesCompute(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 408 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 409 | |
| 410 | // Refresh minion's pillar data |
| 411 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true) |
| 412 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
| 413 | |
| 414 | // Bootstrap all nodes |
| 415 | salt.enforceState(master, 'I@kubernetes:pool', 'linux') |
| 416 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion') |
| 417 | salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp']) |
| 418 | |
| 419 | // Create and distribute SSL certificates for services using salt state |
| 420 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert') |
| 421 | |
| 422 | // Install docker |
| 423 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
| 424 | |
| 425 | // Install Kubernetes and Calico |
| 426 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
| 427 | |
| 428 | } |
| 429 | |
| 430 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 431 | def installDockerSwarm(master) { |
| 432 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 433 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 434 | //Install and Configure Docker |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 435 | salt.enforceState(master, 'I@docker:swarm', 'docker.host') |
| 436 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true) |
| 437 | salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains', true) |
| 438 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update', [], null, true) |
| 439 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules', [], null, true) |
| 440 | sleep(5) |
Martin Polreich | 377c37a | 2017-08-08 15:42:51 +0200 | [diff] [blame] | 441 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 442 | salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm', true) |
| 443 | salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 444 | } |
| 445 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 446 | def installStacklight(master) { |
| 447 | def common = new com.mirantis.mk.Common() |
| 448 | def salt = new com.mirantis.mk.Salt() |
| 449 | |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 450 | // Install haproxy |
| 451 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 452 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
| 453 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 454 | } |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 455 | //Install Telegraf |
Martin Polreich | d894e3e | 2017-07-04 15:35:02 +0200 | [diff] [blame] | 456 | salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 457 | |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 458 | // Install Prometheus exporters |
| 459 | if (salt.testTarget(master, 'I@prometheus:exporters')) { |
| 460 | salt.enforceState(master, 'I@prometheus:exporters', 'prometheus', true) |
| 461 | } |
| 462 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 463 | //Install Elasticsearch and Kibana |
Martin Polreich | bf7f616 | 2017-07-06 14:43:21 +0200 | [diff] [blame] | 464 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true) |
Martin Polreich | a540ac1 | 2017-06-30 22:48:39 +0200 | [diff] [blame] | 465 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true) |
Martin Polreich | bf7f616 | 2017-07-06 14:43:21 +0200 | [diff] [blame] | 466 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 467 | salt.enforceState(master, 'I@kibana:server', 'kibana.server', true) |
Martin Polreich | a540ac1 | 2017-06-30 22:48:39 +0200 | [diff] [blame] | 468 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 469 | salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
Martin Polreich | bf7f616 | 2017-07-06 14:43:21 +0200 | [diff] [blame] | 470 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 471 | salt.enforceState(master, 'I@influxdb:server', 'influxdb', true) |
| 472 | |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 473 | // Install galera |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 474 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 475 | withEnv(['ASK_ON_ERROR=false']){ |
| 476 | retry(2) { |
| 477 | salt.enforceState(master, 'I@galera:master', 'galera', true) |
| 478 | } |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 479 | } |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 480 | salt.enforceState(master, 'I@galera:slave', 'galera', true) |
Martin Polreich | 406f646 | 2017-07-11 11:33:42 +0000 | [diff] [blame] | 481 | |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 482 | // Check galera status |
| 483 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 484 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
| 485 | } |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 486 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 487 | //Collect Grains |
| 488 | salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains', true) |
| 489 | salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules', [], null, true) |
| 490 | salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update', [], null, true) |
| 491 | sleep(5) |
| 492 | |
| 493 | //Configure services in Docker Swarm |
Martin Polreich | 595baef | 2017-07-04 16:11:04 +0200 | [diff] [blame] | 494 | salt.enforceState(master, 'I@docker:swarm', ['prometheus', 'heka.remote_collector'], true, false) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 495 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker', true) |
Martin Polreich | 595baef | 2017-07-04 16:11:04 +0200 | [diff] [blame] | 496 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'dockerng.ps', [], null, true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 497 | |
| 498 | //Configure Grafana |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 499 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 500 | common.prettyPrint(pillar) |
Martin Polreich | 595baef | 2017-07-04 16:11:04 +0200 | [diff] [blame] | 501 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 502 | def stacklight_vip |
| 503 | if(!pillar['return'].isEmpty()) { |
| 504 | stacklight_vip = pillar['return'][0].values()[0] |
| 505 | } else { |
| 506 | common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved') |
| 507 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 508 | |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 509 | common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start") |
Martin Polreich | bd7ad22 | 2017-07-06 12:53:51 +0200 | [diff] [blame] | 510 | sleep(120) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 511 | salt.enforceState(master, 'I@grafana:client', 'grafana.client', true) |
| 512 | |
| 513 | salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector') |
| 514 | } |
| 515 | |
| 516 | def installStacklightv1Control(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 517 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 518 | |
| 519 | // infra install |
| 520 | // Install the StackLight backends |
| 521 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true) |
| 522 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true) |
| 523 | |
| 524 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true) |
| 525 | salt.enforceState(master, 'I@influxdb:server', 'influxdb', true) |
| 526 | |
| 527 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true) |
| 528 | salt.enforceState(master, 'I@kibana:server', 'kibana.server', true) |
| 529 | |
| 530 | salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true) |
| 531 | salt.enforceState(master, 'I@grafana:server','grafana.server', true) |
| 532 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 533 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 534 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
| 535 | |
| 536 | switch (alarming_service) { |
| 537 | case 'sensu': |
| 538 | // Update Sensu |
| 539 | salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq', true) |
| 540 | salt.enforceState(master, 'I@redis:cluster:role:master', 'redis', true) |
| 541 | salt.enforceState(master, 'I@redis:server', 'redis', true) |
| 542 | salt.enforceState(master, 'I@sensu:server', 'sensu', true) |
| 543 | default: |
| 544 | // Update Nagios |
| 545 | salt.enforceState(master, 'I@nagios:server', 'nagios.server', true) |
| 546 | // Stop the Nagios service because the package starts it by default and it will |
| 547 | // started later only on the node holding the VIP address |
| 548 | salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true) |
| 549 | } |
| 550 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 551 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true) |
Marek Celoud | ebc623b | 2017-06-02 17:12:31 +0200 | [diff] [blame] | 552 | salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 553 | |
| 554 | sleep(10) |
| 555 | } |
| 556 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 557 | def installStacklightv1Client(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 558 | def salt = new com.mirantis.mk.Salt() |
| 559 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 560 | |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 561 | 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] | 562 | // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 563 | 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] | 564 | // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
| 565 | |
| 566 | // Install collectd, heka and sensu services on the nodes, this will also |
| 567 | // generate the metadata that goes into the grains and eventually into Salt Mine |
| 568 | salt.enforceState(master, '*', 'collectd', true) |
| 569 | salt.enforceState(master, '*', 'salt.minion', true) |
| 570 | salt.enforceState(master, '*', 'heka', true) |
| 571 | |
| 572 | // Gather the Grafana metadata as grains |
| 573 | salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true) |
| 574 | |
| 575 | // Update Salt Mine |
| 576 | salt.enforceState(master, '*', 'salt.minion.grains', true) |
| 577 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true) |
| 578 | salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true) |
| 579 | |
| 580 | sleep(5) |
| 581 | |
| 582 | // Update Heka |
| 583 | salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true) |
| 584 | |
| 585 | // Update collectd |
| 586 | salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true) |
| 587 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 588 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 589 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 590 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 591 | switch (alarming_service) { |
| 592 | case 'sensu': |
| 593 | // Update Sensu |
| 594 | // TODO for stacklight team, should be fixed in model |
| 595 | salt.enforceState(master, 'I@sensu:client', 'sensu', true) |
| 596 | default: |
| 597 | break |
| 598 | // Default is nagios, and was enforced in installStacklightControl() |
| 599 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 600 | |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 601 | 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] | 602 | // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 603 | |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 604 | // Finalize the configuration of Grafana (add the dashboards...) |
Alexander Noskov | 8448fc5 | 2017-06-21 14:03:45 +0200 | [diff] [blame] | 605 | salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 606 | salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true) |
| 607 | salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true) |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 608 | // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
| 609 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 610 | // Get the StackLight monitoring VIP addres |
| 611 | //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 612 | //vip=${vip:=172.16.10.253} |
| 613 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Jakub Josef | bceaa32 | 2017-06-13 18:28:27 +0200 | [diff] [blame] | 614 | common.prettyPrint(pillar) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 615 | def stacklight_vip = pillar['return'][0].values()[0] |
| 616 | |
| 617 | if (stacklight_vip) { |
| 618 | // (re)Start manually the services that are bound to the monitoring VIP |
| 619 | common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
| 620 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true) |
| 621 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true) |
| 622 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true) |
| 623 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true) |
| 624 | } else { |
| 625 | throw new Exception("Missing stacklight_vip") |
| 626 | } |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 627 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 628 | |
| 629 | |
| 630 | // |
| 631 | // Ceph |
| 632 | // |
| 633 | |
Tomáš Kukrál | 9b4fb51 | 2017-08-14 11:01:49 +0200 | [diff] [blame] | 634 | def installCephMon(master, target='I@ceph:mon') { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 635 | def salt = new com.mirantis.mk.Salt() |
| 636 | |
Ondrej Smola | fd5c235 | 2017-08-11 14:25:39 +0200 | [diff] [blame] | 637 | // install Ceph Mons |
Tomáš Kukrál | 9b4fb51 | 2017-08-14 11:01:49 +0200 | [diff] [blame] | 638 | salt.enforceState(master, target, 'ceph.mon', true) |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | def installCephOsd(master, target='I@ceph:osd') { |
| 642 | def salt = new com.mirantis.mk.Salt() |
| 643 | |
Tomáš Kukrál | 3343a1f | 2017-08-16 12:03:36 +0200 | [diff] [blame] | 644 | // Prapare filesystem on OSD drives |
| 645 | salt.enforceState(master, target, 'linux.storage', true) |
| 646 | |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 647 | // install Ceph OSDs |
| 648 | salt.enforceState(master, target, 'ceph.osd', true) |
| 649 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 650 | |
| 651 | def installCephRadosgw(master, target='I@ceph:radosgw') { |
| 652 | def salt = new com.mirantis.mk.Salt() |
| 653 | |
| 654 | // install Ceph Radosgw |
| 655 | salt.enforceState(master, target, 'ceph.radosgw', true) |
| 656 | } |