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 | |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 17 | def installFoundationInfra(master, staticMgmtNet=false) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 18 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 19 | |
Vasyl Saienko | 0869b3a | 2017-11-22 14:37:57 +0200 | [diff] [blame] | 20 | // NOTE(vsaienko) Apply reclass first, it may update cluster model |
| 21 | // apply linux and salt.master salt.minion states afterwards to make sure |
| 22 | // correct cluster model is used. |
| 23 | salt.enforceState(master, 'I@salt:master', ['reclass'], true) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 24 | |
Vasyl Saienko | 0869b3a | 2017-11-22 14:37:57 +0200 | [diff] [blame] | 25 | salt.enforceState(master, 'I@salt:master', ['linux.system'], true) |
| 26 | salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 27 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true) |
| 28 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
| 29 | |
Vasyl Saienko | e36ab7c | 2017-07-17 14:35:48 +0300 | [diff] [blame] | 30 | 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] | 31 | salt.enforceState(master, 'I@salt:master', ['salt.minion'], true) |
Vasyl Saienko | 0869b3a | 2017-11-22 14:37:57 +0200 | [diff] [blame] | 32 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true) |
| 33 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 34 | |
Jakub Josef | 200550f | 2017-05-16 17:39:55 +0200 | [diff] [blame] | 35 | salt.enforceState(master, '*', ['linux.system'], true) |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 36 | if (staticMgmtNet) { |
| 37 | salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| 38 | } |
Vasyl Saienko | e36ab7c | 2017-07-17 14:35:48 +0300 | [diff] [blame] | 39 | salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp'], true) |
Tomáš Kukrál | 7e767f9 | 2017-08-18 14:53:17 +0200 | [diff] [blame] | 40 | salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2) |
Jakub Josef | 4f8f4df | 2017-09-01 14:32:42 +0200 | [diff] [blame] | 41 | sleep(5) |
| 42 | salt.enforceState(master, '*', ['linux.network.host'], true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 43 | } |
| 44 | |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 45 | def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) { |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 46 | def salt = new com.mirantis.mk.Salt() |
| 47 | |
| 48 | salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2) |
| 49 | |
| 50 | salt.runSaltProcessStep(master, target, 'saltutil.refresh_pillar', [], null, true) |
| 51 | salt.runSaltProcessStep(master, target, 'saltutil.sync_all', [], null, true) |
| 52 | |
| 53 | salt.enforceState(master, target, ['linux.system'], true) |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 54 | if (staticMgmtNet) { |
| 55 | salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| 56 | } |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 57 | salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2) |
| 58 | salt.enforceState(master, target, ['salt.minion'], true) |
| 59 | |
| 60 | salt.enforceState(master, target, ['linux', 'openssh', 'ntp'], true) |
| 61 | sleep(5) |
| 62 | salt.enforceState(master, target, ['linux.network.host'], true) |
| 63 | } |
| 64 | |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 65 | def installInfraKvm(master) { |
| 66 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 67 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 68 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar', [], null, true) |
| 69 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all', [], null, true) |
| 70 | |
Richard Felkl | 286f25f | 2017-07-26 14:23:55 +0200 | [diff] [blame] | 71 | 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] | 72 | 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] | 73 | salt.enforceState(master, 'I@salt:control', 'libvirt', true) |
| 74 | salt.enforceState(master, 'I@salt:control', 'salt.control', true) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 75 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 76 | sleep(600) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 77 | |
Marek Celoud | c9b3cc8 | 2017-05-22 12:50:53 +0000 | [diff] [blame] | 78 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar', [], null, true) |
| 79 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all', [], null, true) |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 80 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 81 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 82 | def installInfra(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 83 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 84 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 85 | // Install glusterfs |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 86 | if (salt.testTarget(master, 'I@glusterfs:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 87 | salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service', true) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 88 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 89 | withEnv(['ASK_ON_ERROR=false']){ |
| 90 | retry(5) { |
| 91 | salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true) |
| 92 | } |
Alexander Noskov | 93acac4 | 2017-06-20 17:55:55 +0200 | [diff] [blame] | 93 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 94 | |
| 95 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true) |
| 96 | 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] | 97 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 98 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 99 | // Ensure glusterfs clusters is ready |
| 100 | if (salt.testTarget(master, 'I@glusterfs:client')) { |
| 101 | salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true) |
| 102 | } |
| 103 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 104 | // Install galera |
Richard Felkl | c0f163e | 2017-07-27 15:11:12 +0200 | [diff] [blame] | 105 | if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 106 | withEnv(['ASK_ON_ERROR=false']){ |
| 107 | retry(2) { |
| 108 | salt.enforceState(master, 'I@galera:master', 'galera', true) |
| 109 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 110 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 111 | salt.enforceState(master, 'I@galera:slave', 'galera', true) |
| 112 | |
| 113 | // Check galera status |
| 114 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 115 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 116 | // If galera is not enabled check if we need to install mysql:server |
| 117 | } else if (salt.testTarget(master, 'I@mysql:server')){ |
| 118 | salt.enforceState(master, 'I@mysql:server', 'mysql.server', true) |
| 119 | if (salt.testTarget(master, 'I@mysql:client')){ |
| 120 | salt.enforceState(master, 'I@mysql:client', 'mysql.client', true) |
| 121 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 122 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 123 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 124 | // Install docker |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 125 | if (salt.testTarget(master, 'I@docker:host')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 126 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
Tomáš Kukrál | 0cf3ffb | 2017-09-03 10:18:18 +0200 | [diff] [blame] | 127 | salt.cmdRun(master, 'I@docker:host', 'docker ps') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 128 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 129 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 130 | // Install keepalived |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 131 | if (salt.testTarget(master, 'I@keepalived:cluster')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 132 | salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived', true) |
| 133 | salt.enforceState(master, 'I@keepalived:cluster', 'keepalived', true) |
| 134 | } |
| 135 | |
| 136 | // Install rabbitmq |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 137 | if (salt.testTarget(master, 'I@rabbitmq:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 138 | withEnv(['ASK_ON_ERROR=false']){ |
| 139 | retry(2) { |
| 140 | salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // Check the rabbitmq status |
| 145 | salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status']) |
| 146 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 147 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 148 | // Install haproxy |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 149 | if (salt.testTarget(master, 'I@haproxy:proxy')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 150 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy', true) |
| 151 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 152 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
| 153 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 154 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 155 | // Install memcached |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 156 | if (salt.testTarget(master, 'I@memcached:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 157 | salt.enforceState(master, 'I@memcached:server', 'memcached', true) |
| 158 | } |
| 159 | |
| 160 | // Install etcd |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 161 | if (salt.testTarget(master, 'I@etcd:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 162 | salt.enforceState(master, 'I@etcd:server', 'etcd.server.service') |
vrovachev | 076e5c9 | 2017-11-13 18:56:17 +0400 | [diff] [blame] | 163 | salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
| 167 | def installOpenstackInfra(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 168 | def orchestrate = new com.mirantis.mk.Orchestrate() |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 169 | |
| 170 | // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 171 | orchestrate.installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 175 | def installOpenstackControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 176 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 177 | |
| 178 | // Install horizon dashboard |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 179 | if (salt.testTarget(master, 'I@horizon:server')) { |
| 180 | salt.enforceState(master, 'I@horizon:server', 'horizon', true) |
| 181 | } |
| 182 | if (salt.testTarget(master, 'I@nginx:server')) { |
Richard Felkl | 34e1b99 | 2017-11-02 23:15:06 +0100 | [diff] [blame] | 183 | salt.enforceState(master, 'I@nginx:server', 'salt.minion', true) |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 184 | salt.enforceState(master, 'I@nginx:server', 'nginx', true) |
| 185 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 186 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 187 | // setup keystone service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 188 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 189 | //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1) |
| 190 | salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server', true) |
| 191 | salt.enforceState(master, 'I@keystone:server', 'keystone.server', true) |
| 192 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 193 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 194 | // keystone:client must be called locally |
| 195 | //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| 196 | salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2']) |
| 197 | sleep(30) |
| 198 | } |
| 199 | if (salt.testTarget(master, 'I@keystone:client')) { |
Vasyl Saienko | ff6f0f0 | 2017-07-19 15:54:16 +0300 | [diff] [blame] | 200 | salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client', true) |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 201 | salt.enforceState(master, 'I@keystone:client', 'keystone.client', true) |
| 202 | } |
| 203 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 204 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonercv3; openstack service list'], null, true) |
| 205 | } |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 206 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 207 | // Install glance |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 208 | if (salt.testTarget(master, 'I@glance:server')) { |
| 209 | //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
| 210 | salt.enforceState(master, 'I@glance:server and *01*', 'glance.server', true) |
| 211 | salt.enforceState(master, 'I@glance:server', 'glance.server', true) |
| 212 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 213 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 214 | // Check glance service |
| 215 | if (salt.testTarget(master, 'I@glance:server')){ |
| 216 | 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] | 217 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 218 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 219 | // Create glance resources |
| 220 | if (salt.testTarget(master, 'I@glance:client')) { |
| 221 | salt.enforceState(master, 'I@glance:client', 'glance.client', true) |
| 222 | } |
| 223 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 224 | // Install and check nova service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 225 | if (salt.testTarget(master, 'I@nova:controller')) { |
| 226 | //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1) |
| 227 | salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller', true) |
| 228 | salt.enforceState(master, 'I@nova:controller', 'nova.controller', true) |
| 229 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 230 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true) |
| 231 | } |
| 232 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 233 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 234 | // Create nova resources |
| 235 | if (salt.testTarget(master, 'I@nova:client')) { |
| 236 | salt.enforceState(master, 'I@nova:client', 'nova.client', true) |
| 237 | } |
| 238 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 239 | // Install and check cinder service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 240 | if (salt.testTarget(master, 'I@cinder:controller')) { |
| 241 | //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1) |
| 242 | salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder', true) |
| 243 | salt.enforceState(master, 'I@cinder:controller', 'cinder', true) |
| 244 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 245 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true) |
| 246 | } |
| 247 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 248 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 249 | // Install neutron service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 250 | if (salt.testTarget(master, 'I@neutron:server')) { |
| 251 | //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 252 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 253 | salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server', true) |
| 254 | salt.enforceState(master, 'I@neutron:server', 'neutron.server', true) |
| 255 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 256 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true) |
| 257 | } |
| 258 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 259 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 260 | // Create neutron resources |
| 261 | if (salt.testTarget(master, 'I@neutron:client')) { |
| 262 | salt.enforceState(master, 'I@neutron:client', 'neutron.client', true) |
| 263 | } |
| 264 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 265 | // Install heat service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 266 | if (salt.testTarget(master, 'I@heat:server')) { |
| 267 | //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1) |
| 268 | salt.enforceState(master, 'I@heat:server and *01*', 'heat', true) |
| 269 | salt.enforceState(master, 'I@heat:server', 'heat', true) |
| 270 | if (salt.testTarget(master, 'I@keystone:server')) { |
| 271 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true) |
| 272 | } |
| 273 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 274 | |
| 275 | // Restart nova api |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 276 | if (salt.testTarget(master, 'I@nova:controller')) { |
| 277 | salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api']) |
| 278 | } |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 279 | |
| 280 | // Install ironic service |
| 281 | if (salt.testTarget(master, 'I@ironic:api')) { |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 282 | salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api', true) |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 283 | salt.enforceState(master, 'I@ironic:api', 'ironic.api', true) |
| 284 | } |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 285 | |
| 286 | // Install designate service |
| 287 | if (salt.testTarget(master, 'I@designate:server:enabled')) { |
| 288 | if (salt.testTarget(master, 'I@designate:server:backend:bind9')) { |
| 289 | salt.enforceState(master, 'I@bind:server', 'bind.server', true) |
| 290 | } |
| 291 | if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) { |
| 292 | salt.enforceState(master, 'I@powerdns:server', 'powerdns.server', true) |
| 293 | } |
| 294 | salt.enforceState(master, 'I@designate:server and *01*', 'designate.server', true) |
| 295 | salt.enforceState(master, 'I@designate:server', 'designate.server', true) |
| 296 | } |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 297 | |
| 298 | // Install octavia api service |
| 299 | if (salt.testTarget(master, 'I@octavia:api')) { |
| 300 | salt.enforceState(master, 'I@octavia:api', 'octavia', true) |
| 301 | } |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 302 | |
Oleg Iurchenko | d0898c9 | 2017-12-14 14:28:44 +0200 | [diff] [blame] | 303 | // Install DogTag server service |
| 304 | if (salt.testTarget(master, 'I@dogtag:server')) { |
| 305 | salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server', true) |
| 306 | salt.enforceState(master, 'I@dogtag:server', 'dogtag.server', true) |
| 307 | } |
| 308 | |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 309 | // Install barbican server service |
| 310 | if (salt.testTarget(master, 'I@barbican:server')) { |
Petr Jediný | 1c71703 | 2017-11-03 13:37:34 +0100 | [diff] [blame] | 311 | salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server', true) |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 312 | salt.enforceState(master, 'I@barbican:server', 'barbican.server', true) |
| 313 | } |
| 314 | // Install barbican client |
| 315 | if (salt.testTarget(master, 'I@barbican:client')) { |
| 316 | salt.enforceState(master, 'I@barbican:client', 'barbican.client', true) |
| 317 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 321 | def installIronicConductor(master){ |
| 322 | def salt = new com.mirantis.mk.Salt() |
| 323 | |
| 324 | if (salt.testTarget(master, 'I@ironic:conductor')) { |
| 325 | salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor', true) |
| 326 | salt.enforceState(master, 'I@ironic:conductor', 'apache', true) |
| 327 | } |
| 328 | if (salt.testTarget(master, 'I@tftpd_hpa:server')) { |
| 329 | salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa', true) |
| 330 | } |
| 331 | |
| 332 | if (salt.testTarget(master, 'I@nova:compute')) { |
| 333 | salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute']) |
| 334 | } |
| 335 | |
| 336 | if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) { |
| 337 | salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator', true) |
| 338 | } |
| 339 | if (salt.testTarget(master, 'I@ironic:client')) { |
| 340 | salt.enforceState(master, 'I@ironic:client', 'ironic.client', true) |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | |
| 345 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 346 | def installOpenstackNetwork(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 347 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 348 | |
| 349 | salt.runSaltProcessStep(master, 'I@neutron:gateway', 'state.apply', [], null, true) |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 350 | |
| 351 | // install octavia manager services |
| 352 | if (salt.testTarget(master, 'I@octavia:manager')) { |
| 353 | salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*'], null, true) |
Anastasia Kuznetsova | 38aee7d | 2017-09-12 14:28:17 +0400 | [diff] [blame] | 354 | salt.enforceState(master, 'I@octavia:manager', 'octavia', true) |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 355 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca', true) |
| 356 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert', true) |
| 357 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | |
| 361 | def installOpenstackCompute(master) { |
| 362 | def salt = new com.mirantis.mk.Salt() |
| 363 | |
| 364 | // Configure compute nodes |
| 365 | retry(2) { |
Marek Celoud | e305ec7 | 2017-05-16 11:27:53 +0200 | [diff] [blame] | 366 | 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] | 367 | } |
| 368 | } |
| 369 | |
| 370 | |
| 371 | def installContrailNetwork(master) { |
Martin Polreich | fc9854c | 2017-06-30 11:17:36 +0200 | [diff] [blame] | 372 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 373 | def salt = new com.mirantis.mk.Salt() |
| 374 | |
| 375 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 376 | // Install opencontrail database services |
| 377 | //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1) |
Jakub Josef | 0e17ec0 | 2017-11-28 13:49:41 +0100 | [diff] [blame] | 378 | if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){ |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 379 | salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 380 | salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database', true) |
Jakub Josef | 0e17ec0 | 2017-11-28 13:49:41 +0100 | [diff] [blame] | 381 | }else{ |
| 382 | try { |
| 383 | salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true) |
| 384 | } catch (Exception e) { |
| 385 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database and *01*') |
| 386 | } |
| 387 | try { |
| 388 | salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database', true) |
| 389 | } catch (Exception e) { |
| 390 | common.warningMsg('Exception in state opencontrail.database on I@opencontrail:database') |
| 391 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 392 | } |
| 393 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 394 | // Install opencontrail control services |
| 395 | //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 396 | salt.runSaltProcessStep(master, 'I@opencontrail:control and *01*', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 397 | salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 398 | 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] | 399 | |
Marek Celoud | 443fb64 | 2017-11-22 15:07:12 +0100 | [diff] [blame] | 400 | if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) { |
| 401 | salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client', true) |
| 402 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 406 | def installContrailCompute(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 407 | def salt = new com.mirantis.mk.Salt() |
vrovachev | 32f7f54 | 2017-08-25 16:17:25 +0400 | [diff] [blame] | 408 | def common = new com.mirantis.mk.Common() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 409 | // Configure compute nodes |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 410 | // Provision opencontrail control services |
| 411 | salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client', true) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 412 | // Provision opencontrail virtual routers |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 413 | |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 414 | // Generate script /usr/lib/contrail/if-vhost0 for up vhost0 |
Jakub Josef | 0e17ec0 | 2017-11-28 13:49:41 +0100 | [diff] [blame] | 415 | if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){ |
Marek Celoud | 443fb64 | 2017-11-22 15:07:12 +0100 | [diff] [blame] | 416 | salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
Jakub Josef | 0e17ec0 | 2017-11-28 13:49:41 +0100 | [diff] [blame] | 417 | }else{ |
| 418 | try { |
| 419 | salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail', 'exclude=opencontrail.client']) |
| 420 | } catch (Exception e) { |
| 421 | common.warningMsg('Exception in state opencontrail on I@opencontrail:compute') |
| 422 | } |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 423 | } |
| 424 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 425 | 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] | 426 | |
| 427 | if (salt.testTarget(master, 'I@opencontrail:compute')) { |
| 428 | sleep(300) |
| 429 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client', true) |
| 430 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail', true) |
| 431 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 435 | def installKubernetesInfra(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 436 | def orchestrate = new com.mirantis.mk.Orchestrate() |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 437 | // THIS FUNCTION IS LEGACY, PLEASE USE installInfra directly |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 438 | orchestrate.installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | |
Tomáš Kukrál | c1a1bbc | 2017-04-28 21:16:25 +0200 | [diff] [blame] | 442 | def installKubernetesControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 443 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 444 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 445 | // Install Kubernetes pool and Calico |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 446 | salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons') |
| 447 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 448 | |
Marek Celoud | 029391c | 2017-11-14 10:06:18 +0100 | [diff] [blame] | 449 | if (salt.testTarget(master, 'I@etcd:server:setup')) { |
| 450 | // Setup etcd server |
| 451 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup') |
| 452 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 453 | |
| 454 | // Run k8s without master.setup |
| 455 | salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup']) |
| 456 | |
| 457 | // Run k8s master setup |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 458 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 459 | |
| 460 | // Restart kubelet |
| 461 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
| 462 | } |
| 463 | |
| 464 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 465 | def installKubernetesCompute(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 466 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 467 | |
| 468 | // Refresh minion's pillar data |
| 469 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_pillar', [], null, true) |
| 470 | salt.runSaltProcessStep(master, '*', 'saltutil.sync_all', [], null, true) |
| 471 | |
| 472 | // Bootstrap all nodes |
| 473 | salt.enforceState(master, 'I@kubernetes:pool', 'linux') |
| 474 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion') |
| 475 | salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp']) |
| 476 | |
| 477 | // Create and distribute SSL certificates for services using salt state |
| 478 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert') |
| 479 | |
| 480 | // Install docker |
| 481 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
| 482 | |
| 483 | // Install Kubernetes and Calico |
| 484 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
| 485 | |
Yuriy Taraday | ab564d7 | 2017-10-11 15:14:35 +0400 | [diff] [blame] | 486 | // Install Tiller and all configured releases |
| 487 | if (salt.testTarget(master, 'I@helm:client')) { |
| 488 | salt.enforceState(master, 'I@helm:client', 'helm') |
| 489 | } |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 493 | def installDockerSwarm(master) { |
| 494 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 495 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 496 | //Install and Configure Docker |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 497 | salt.enforceState(master, 'I@docker:swarm', 'docker.host') |
| 498 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true) |
| 499 | salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains', true) |
| 500 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update', [], null, true) |
| 501 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules', [], null, true) |
| 502 | sleep(5) |
Martin Polreich | 377c37a | 2017-08-08 15:42:51 +0200 | [diff] [blame] | 503 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 504 | salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm', true) |
| 505 | salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 506 | } |
| 507 | |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 508 | |
| 509 | def installCicd(master) { |
| 510 | def salt = new com.mirantis.mk.Salt() |
| 511 | |
| 512 | //Install and Configure Docker |
Richard Felkl | 9d2cd92 | 2017-11-03 11:49:32 +0100 | [diff] [blame] | 513 | salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.refresh_pillar', [], null, true) |
| 514 | salt.runSaltProcessStep(master, 'I@jenkins:client or I@gerrit:client', 'saltutil.sync_all', [], null, true) |
| 515 | |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 516 | if (salt.testTarget(master, 'I@aptly:publisher')) { |
| 517 | salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2) |
| 518 | } |
| 519 | |
Richard Felkl | 6de1676 | 2017-11-20 11:42:28 +0100 | [diff] [blame] | 520 | salt.enforceState(master, 'I@docker:swarm:role:master and I@jenkins:client', 'docker.client', true, true, null, false, -1, 2) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 521 | sleep(500) |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 522 | |
| 523 | if (salt.testTarget(master, 'I@aptly:server')) { |
| 524 | salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2) |
| 525 | } |
| 526 | |
| 527 | if (salt.testTarget(master, 'I@openldap:client')) { |
| 528 | salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2) |
| 529 | } |
Richard Felkl | b6fdec9 | 2017-09-26 10:52:36 +0200 | [diff] [blame] | 530 | |
| 531 | if (salt.testTarget(master, 'I@python:environment')) { |
| 532 | salt.enforceState(master, 'I@python:environment', 'python', true) |
| 533 | } |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 534 | |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 535 | withEnv(['ASK_ON_ERROR=false']){ |
| 536 | retry(2){ |
| 537 | try{ |
| 538 | salt.enforceState(master, 'I@gerrit:client', 'gerrit', true) |
| 539 | }catch(e){ |
| 540 | salt.runSaltProcessStep(master, 'I@gerrit:client', 'saltutil.refresh_pillar', [], null, true) |
| 541 | salt.runSaltProcessStep(master, 'I@gerrit:client', 'saltutil.sync_all', [], null, true) |
| 542 | throw e //rethrow for retry handler |
| 543 | } |
| 544 | } |
| 545 | retry(2){ |
| 546 | try{ |
| 547 | salt.enforceState(master, 'I@jenkins:client', 'jenkins', true) |
| 548 | }catch(e){ |
| 549 | salt.runSaltProcessStep(master, 'I@jenkins:client', 'saltutil.refresh_pillar', [], null, true) |
| 550 | salt.runSaltProcessStep(master, 'I@jenkins:client', 'saltutil.sync_all', [], null, true) |
| 551 | throw e //rethrow for retry handler |
| 552 | } |
| 553 | } |
| 554 | } |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 558 | def installStacklight(master) { |
| 559 | def common = new com.mirantis.mk.Common() |
| 560 | def salt = new com.mirantis.mk.Salt() |
| 561 | |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 562 | // Install core services for K8S environments: |
| 563 | // HAProxy, Nginx and lusterFS clients |
| 564 | // In case of OpenStack, those are already installed |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 565 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 566 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
| 567 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 568 | |
| 569 | if (salt.testTarget(master, 'I@nginx:server')) { |
| 570 | salt.enforceState(master, 'I@nginx:server', 'nginx', true) |
| 571 | } |
| 572 | |
| 573 | if (salt.testTarget(master, 'I@glusterfs:client')) { |
| 574 | salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true) |
| 575 | } |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 576 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 577 | |
| 578 | // Launch containers |
| 579 | salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client', true) |
| 580 | salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps', [], null, true) |
| 581 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 582 | //Install Telegraf |
Martin Polreich | d894e3e | 2017-07-04 15:35:02 +0200 | [diff] [blame] | 583 | 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] | 584 | |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 585 | // Install Prometheus exporters |
| 586 | if (salt.testTarget(master, 'I@prometheus:exporters')) { |
| 587 | salt.enforceState(master, 'I@prometheus:exporters', 'prometheus', true) |
| 588 | } |
| 589 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 590 | //Install Elasticsearch and Kibana |
Martin Polreich | bf7f616 | 2017-07-06 14:43:21 +0200 | [diff] [blame] | 591 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true) |
Martin Polreich | a540ac1 | 2017-06-30 22:48:39 +0200 | [diff] [blame] | 592 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true) |
Martin Polreich | bf7f616 | 2017-07-06 14:43:21 +0200 | [diff] [blame] | 593 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 594 | salt.enforceState(master, 'I@kibana:server', 'kibana.server', true) |
Martin Polreich | a540ac1 | 2017-06-30 22:48:39 +0200 | [diff] [blame] | 595 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 596 | salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
Martin Polreich | bf7f616 | 2017-07-06 14:43:21 +0200 | [diff] [blame] | 597 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 598 | salt.enforceState(master, 'I@influxdb:server', 'influxdb', true) |
| 599 | |
Simon Pasquier | 6301ddd | 2017-09-05 11:56:58 +0200 | [diff] [blame] | 600 | salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector') |
| 601 | |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 602 | // Install galera |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 603 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 604 | withEnv(['ASK_ON_ERROR=false']){ |
| 605 | retry(2) { |
| 606 | salt.enforceState(master, 'I@galera:master', 'galera', true) |
| 607 | } |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 608 | } |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 609 | salt.enforceState(master, 'I@galera:slave', 'galera', true) |
Martin Polreich | 406f646 | 2017-07-11 11:33:42 +0000 | [diff] [blame] | 610 | |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 611 | // Check galera status |
| 612 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 613 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
| 614 | } |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 615 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 616 | //Collect Grains |
| 617 | salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains', true) |
| 618 | salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules', [], null, true) |
| 619 | salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update', [], null, true) |
| 620 | sleep(5) |
| 621 | |
| 622 | //Configure services in Docker Swarm |
Martin Polreich | 8017f45 | 2017-08-21 16:01:42 +0200 | [diff] [blame] | 623 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 624 | salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus', true, false) |
| 625 | } |
| 626 | else { |
| 627 | salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', ['prometheus', 'heka.remote_collector'], true, false) |
| 628 | } |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 629 | |
| 630 | //Configure Grafana |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 631 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 632 | common.prettyPrint(pillar) |
Martin Polreich | 595baef | 2017-07-04 16:11:04 +0200 | [diff] [blame] | 633 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 634 | def stacklight_vip |
| 635 | if(!pillar['return'].isEmpty()) { |
| 636 | stacklight_vip = pillar['return'][0].values()[0] |
| 637 | } else { |
| 638 | common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved') |
| 639 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 640 | |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 641 | common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start") |
Martin Polreich | bd7ad22 | 2017-07-06 12:53:51 +0200 | [diff] [blame] | 642 | sleep(120) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 643 | salt.enforceState(master, 'I@grafana:client', 'grafana.client', true) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | def installStacklightv1Control(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 647 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 648 | |
| 649 | // infra install |
| 650 | // Install the StackLight backends |
| 651 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server', true) |
| 652 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server', true) |
| 653 | |
| 654 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb', true) |
| 655 | salt.enforceState(master, 'I@influxdb:server', 'influxdb', true) |
| 656 | |
| 657 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server', true) |
| 658 | salt.enforceState(master, 'I@kibana:server', 'kibana.server', true) |
| 659 | |
| 660 | salt.enforceState(master, '*01* and I@grafana:server','grafana.server', true) |
| 661 | salt.enforceState(master, 'I@grafana:server','grafana.server', true) |
| 662 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 663 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 664 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
| 665 | |
| 666 | switch (alarming_service) { |
| 667 | case 'sensu': |
| 668 | // Update Sensu |
| 669 | salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq', true) |
| 670 | salt.enforceState(master, 'I@redis:cluster:role:master', 'redis', true) |
| 671 | salt.enforceState(master, 'I@redis:server', 'redis', true) |
| 672 | salt.enforceState(master, 'I@sensu:server', 'sensu', true) |
| 673 | default: |
| 674 | // Update Nagios |
| 675 | salt.enforceState(master, 'I@nagios:server', 'nagios.server', true) |
| 676 | // Stop the Nagios service because the package starts it by default and it will |
| 677 | // started later only on the node holding the VIP address |
| 678 | salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true) |
| 679 | } |
| 680 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 681 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service', true) |
Marek Celoud | ebc623b | 2017-06-02 17:12:31 +0200 | [diff] [blame] | 682 | salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 683 | |
| 684 | sleep(10) |
| 685 | } |
| 686 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 687 | def installStacklightv1Client(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 688 | def salt = new com.mirantis.mk.Salt() |
| 689 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 690 | |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 691 | 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] | 692 | // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 693 | 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] | 694 | // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
| 695 | |
| 696 | // Install collectd, heka and sensu services on the nodes, this will also |
| 697 | // generate the metadata that goes into the grains and eventually into Salt Mine |
| 698 | salt.enforceState(master, '*', 'collectd', true) |
| 699 | salt.enforceState(master, '*', 'salt.minion', true) |
| 700 | salt.enforceState(master, '*', 'heka', true) |
| 701 | |
| 702 | // Gather the Grafana metadata as grains |
| 703 | salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true) |
| 704 | |
| 705 | // Update Salt Mine |
| 706 | salt.enforceState(master, '*', 'salt.minion.grains', true) |
| 707 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules', [], null, true) |
| 708 | salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true) |
| 709 | |
| 710 | sleep(5) |
| 711 | |
| 712 | // Update Heka |
| 713 | salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka', true) |
| 714 | |
| 715 | // Update collectd |
| 716 | salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd', true) |
| 717 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 718 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 719 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 720 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 721 | switch (alarming_service) { |
| 722 | case 'sensu': |
| 723 | // Update Sensu |
| 724 | // TODO for stacklight team, should be fixed in model |
| 725 | salt.enforceState(master, 'I@sensu:client', 'sensu', true) |
| 726 | default: |
| 727 | break |
| 728 | // Default is nagios, and was enforced in installStacklightControl() |
| 729 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 730 | |
Alexander Noskov | 3c6a60a | 2017-06-21 14:05:07 +0200 | [diff] [blame] | 731 | 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] | 732 | // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 733 | |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 734 | // Finalize the configuration of Grafana (add the dashboards...) |
Alexander Noskov | 8448fc5 | 2017-06-21 14:03:45 +0200 | [diff] [blame] | 735 | salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 736 | salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client', true) |
| 737 | salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client', true) |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 738 | // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
| 739 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 740 | // Get the StackLight monitoring VIP addres |
| 741 | //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 742 | //vip=${vip:=172.16.10.253} |
| 743 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Jakub Josef | bceaa32 | 2017-06-13 18:28:27 +0200 | [diff] [blame] | 744 | common.prettyPrint(pillar) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 745 | def stacklight_vip = pillar['return'][0].values()[0] |
| 746 | |
| 747 | if (stacklight_vip) { |
| 748 | // (re)Start manually the services that are bound to the monitoring VIP |
| 749 | common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
| 750 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd'], null, true) |
| 751 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector'], null, true) |
| 752 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator'], null, true) |
| 753 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3'], null, true) |
| 754 | } else { |
| 755 | throw new Exception("Missing stacklight_vip") |
| 756 | } |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 757 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 758 | |
| 759 | |
| 760 | // |
| 761 | // Ceph |
| 762 | // |
| 763 | |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 764 | def installCephMon(master, target='I@ceph:mon') { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 765 | def salt = new com.mirantis.mk.Salt() |
| 766 | |
Jiri Broulik | bfc234f | 2017-10-17 15:45:38 +0200 | [diff] [blame] | 767 | salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains', true) |
| 768 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 769 | // generate keyrings |
| 770 | if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) { |
| 771 | salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon', true) |
Jiri Broulik | 07f8de7 | 2017-10-09 14:12:17 +0200 | [diff] [blame] | 772 | salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains', [], null, true) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 773 | salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update', [], null, true) |
Jiri Broulik | 3c75a6d | 2017-10-06 18:44:37 +0200 | [diff] [blame] | 774 | sleep(5) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 775 | } |
Ondrej Smola | fd5c235 | 2017-08-11 14:25:39 +0200 | [diff] [blame] | 776 | // install Ceph Mons |
Tomáš Kukrál | 9b4fb51 | 2017-08-14 11:01:49 +0200 | [diff] [blame] | 777 | salt.enforceState(master, target, 'ceph.mon', true) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 778 | if (salt.testTarget(master, 'I@ceph:mgr')) { |
Jiri Broulik | 3c75a6d | 2017-10-06 18:44:37 +0200 | [diff] [blame] | 779 | salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr', true) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 780 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 781 | } |
| 782 | |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 783 | def installCephOsd(master, target='I@ceph:osd', setup=true) { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 784 | def salt = new com.mirantis.mk.Salt() |
| 785 | |
| 786 | // install Ceph OSDs |
| 787 | salt.enforceState(master, target, 'ceph.osd', true) |
Jiri Broulik | 07f8de7 | 2017-10-09 14:12:17 +0200 | [diff] [blame] | 788 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 789 | salt.enforceState(master, target, 'ceph.osd.custom', true) |
Jiri Broulik | 2911deb | 2017-10-12 20:26:43 +0200 | [diff] [blame] | 790 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains', [], null, true) |
| 791 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update', [], null, true) |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 792 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 793 | // setup pools, keyrings and maybe crush |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 794 | if (salt.testTarget(master, 'I@ceph:setup') && setup) { |
Jiri Broulik | 07f8de7 | 2017-10-09 14:12:17 +0200 | [diff] [blame] | 795 | sleep(5) |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 796 | salt.enforceState(master, 'I@ceph:setup', 'ceph.setup', true) |
| 797 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 798 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 799 | |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 800 | def installCephClient(master) { |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 801 | def salt = new com.mirantis.mk.Salt() |
| 802 | |
| 803 | // install Ceph Radosgw |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 804 | if (salt.testTarget(master, 'I@ceph:radosgw')) { |
Jiri Broulik | bfc234f | 2017-10-17 15:45:38 +0200 | [diff] [blame] | 805 | salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains', [], null, true) |
Tomáš Kukrál | 1fe9045 | 2017-08-28 18:27:26 +0200 | [diff] [blame] | 806 | salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw', true) |
Alexander Noskov | 229035f | 2017-12-06 00:10:20 +0400 | [diff] [blame] | 807 | } |
| 808 | // setup Keystone service and endpoints for swift or / and S3 |
| 809 | if (salt.testTarget(master, 'I@keystone:client')) { |
Jiri Broulik | 831a74e | 2017-10-18 08:27:11 +0200 | [diff] [blame] | 810 | salt.enforceState(master, 'I@keystone:client', 'keystone.client', true) |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 811 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 812 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 813 | |
| 814 | def connectCeph(master) { |
| 815 | def salt = new com.mirantis.mk.Salt() |
| 816 | |
| 817 | // connect Ceph to the env |
| 818 | if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) { |
| 819 | salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance'], true) |
| 820 | salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry']) |
| 821 | } |
| 822 | if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) { |
| 823 | salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder'], true) |
| 824 | } |
| 825 | if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) { |
| 826 | salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring'], true) |
Jiri Broulik | 07f8de7 | 2017-10-09 14:12:17 +0200 | [diff] [blame] | 827 | salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains', [], null, true) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 828 | salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova'], true) |
| 829 | } |
| 830 | } |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 831 | |
| 832 | def installOssInfra(master) { |
| 833 | def common = new com.mirantis.mk.Common() |
| 834 | def salt = new com.mirantis.mk.Salt() |
| 835 | |
Mikhail Ivanov | 788996c | 2017-12-15 14:28:57 +0400 | [diff] [blame] | 836 | if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) { |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 837 | def orchestrate = new com.mirantis.mk.Orchestrate() |
| 838 | orchestrate.installInfra(master) |
| 839 | } |
| 840 | |
| 841 | if (salt.testTarget(master, 'I@devops_portal:config')) { |
| 842 | salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config', true) |
| 843 | salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh'], true) |
| 844 | salt.enforceState(master, 'I@rundeck:server', 'rundeck.server', true) |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | def installOss(master) { |
| 849 | def common = new com.mirantis.mk.Common() |
| 850 | def salt = new com.mirantis.mk.Salt() |
| 851 | |
| 852 | //Get oss VIP address |
| 853 | def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address') |
| 854 | common.prettyPrint(pillar) |
| 855 | |
| 856 | def oss_vip |
| 857 | if(!pillar['return'].isEmpty()) { |
| 858 | oss_vip = pillar['return'][0].values()[0] |
| 859 | } else { |
| 860 | common.errorMsg('[ERROR] Oss VIP address could not be retrieved') |
| 861 | } |
| 862 | |
| 863 | // Postgres client - initialize OSS services databases |
| 864 | timeout(120){ |
| 865 | common.infoMsg("Waiting for postgresql database to come up..") |
| 866 | salt.cmdRun(master, 'I@postgresql:client', 'while true; do if docker service logs postgresql_postgresql-db | grep "ready to accept"; then break; else sleep 5; fi; done') |
| 867 | } |
| 868 | // XXX: first run usually fails on some inserts, but we need to create databases at first |
| 869 | salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false) |
| 870 | |
| 871 | // Setup postgres database with integration between |
| 872 | // Pushkin notification service and Security Monkey security audit service |
| 873 | timeout(10) { |
| 874 | common.infoMsg("Waiting for Pushkin to come up..") |
| 875 | salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done") |
| 876 | } |
| 877 | salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true) |
| 878 | |
| 879 | // Rundeck |
| 880 | timeout(10) { |
| 881 | common.infoMsg("Waiting for Rundeck to come up..") |
| 882 | salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done") |
| 883 | } |
| 884 | salt.enforceState(master, 'I@rundeck:client', 'rundeck.client', true) |
| 885 | |
| 886 | // Elasticsearch |
Mikhail Ivanov | fcd55d6 | 2017-12-19 16:51:35 +0400 | [diff] [blame] | 887 | pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host') |
| 888 | def elasticsearch_vip |
| 889 | if(!pillar['return'].isEmpty()) { |
| 890 | elasticsearch_vip = pillar['return'][0].values()[0] |
| 891 | } else { |
| 892 | common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| 893 | } |
| 894 | |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 895 | timeout(10) { |
| 896 | common.infoMsg('Waiting for Elasticsearch to come up..') |
Mikhail Ivanov | fcd55d6 | 2017-12-19 16:51:35 +0400 | [diff] [blame] | 897 | salt.cmdRun(master, 'I@elasticsearch:client', "while true; do curl -sf ${elasticsearch_vip}:9200 >/dev/null && break; done") |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 898 | } |
| 899 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
| 900 | } |