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