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 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 10 | salt.cmdRun(master, 'I@salt:master' ,'salt-key') |
| 11 | salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version') |
| 12 | salt.cmdRun(master, 'I@salt:master' ,'reclass-salt --top') |
| 13 | salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory') |
| 14 | salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top') |
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() |
Jiri Broulik | 037f898 | 2018-04-23 17:07:16 +0200 | [diff] [blame] | 19 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 20 | |
Vasyl Saienko | 0869b3a | 2017-11-22 14:37:57 +0200 | [diff] [blame] | 21 | // NOTE(vsaienko) Apply reclass first, it may update cluster model |
| 22 | // apply linux and salt.master salt.minion states afterwards to make sure |
| 23 | // correct cluster model is used. |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 24 | salt.enforceState(master, 'I@salt:master', ['reclass']) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 25 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 26 | salt.enforceState(master, 'I@salt:master', ['linux.system']) |
Vasyl Saienko | 0869b3a | 2017-11-22 14:37:57 +0200 | [diff] [blame] | 27 | salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 28 | salt.fullRefresh(master, "*") |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 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) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 31 | salt.enforceState(master, 'I@salt:master', ['salt.minion']) |
| 32 | salt.fullRefresh(master, "*") |
Ondrej Smola | a9b8466 | 2018-04-18 11:22:19 +0200 | [diff] [blame] | 33 | salt.enforceState(master, '*', ['linux.network.proxy'], true, false, null, false, 60, 2) |
Jiri Broulik | 94fc259 | 2018-04-20 13:47:51 +0200 | [diff] [blame] | 34 | try { |
| 35 | salt.enforceState(master, '*', ['salt.minion.base'], true, false, null, false, 60, 2) |
| 36 | sleep(5) |
| 37 | } catch (Throwable e) { |
| 38 | common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.') |
| 39 | } |
Jiri Broulik | e3ace62 | 2018-06-07 10:51:02 +0200 | [diff] [blame] | 40 | common.retry(2,5){ |
| 41 | salt.enforceState(master, '*', ['linux.system']) |
| 42 | } |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 43 | if (staticMgmtNet) { |
| 44 | salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| 45 | } |
Jiri Broulik | 3740fb9 | 2018-04-27 11:52:38 +0200 | [diff] [blame] | 46 | salt.enforceState(master, 'I@linux:network:interface', ['linux.network.interface']) |
Jiri Broulik | 9453846 | 2018-05-11 15:45:13 +0200 | [diff] [blame] | 47 | sleep(5) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 48 | salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog']) |
Tomáš Kukrál | 7e767f9 | 2017-08-18 14:53:17 +0200 | [diff] [blame] | 49 | salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2) |
Jakub Josef | 4f8f4df | 2017-09-01 14:32:42 +0200 | [diff] [blame] | 50 | sleep(5) |
Victor Ryzhenkin | f610c57 | 2018-05-15 15:22:52 +0400 | [diff] [blame] | 51 | |
| 52 | salt.fullRefresh(master, "*") |
vrovachev | c4424a3 | 2018-03-15 17:35:57 +0400 | [diff] [blame] | 53 | salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 54 | salt.enforceState(master, '*', ['linux.network.host']) |
Ivan Suzdal | 9a6bc39 | 2018-04-26 18:29:56 +0400 | [diff] [blame] | 55 | |
| 56 | // Install and configure iptables |
| 57 | if (salt.testTarget(master, 'I@iptables:service')) { |
| 58 | salt.enforceState(master, 'I@iptables:service', 'iptables') |
| 59 | } |
sgarbuz | bb61e81 | 2018-05-03 16:58:40 +0300 | [diff] [blame] | 60 | |
| 61 | // Install and configure logrotate |
| 62 | if (salt.testTarget(master, 'I@logrotate:server')) { |
| 63 | salt.enforceState(master, 'I@logrotate:server', 'logrotate') |
| 64 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 65 | } |
| 66 | |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 67 | def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) { |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 68 | def salt = new com.mirantis.mk.Salt() |
Jiri Broulik | 9fb138a | 2018-04-23 17:13:00 +0200 | [diff] [blame] | 69 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 70 | |
| 71 | salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 72 | salt.fullRefresh(master, target) |
Ondrej Smola | a9b8466 | 2018-04-18 11:22:19 +0200 | [diff] [blame] | 73 | salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2) |
Jiri Broulik | 94fc259 | 2018-04-20 13:47:51 +0200 | [diff] [blame] | 74 | try { |
| 75 | salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2) |
| 76 | sleep(5) |
| 77 | } catch (Throwable e) { |
| 78 | common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.') |
| 79 | } |
Jiri Broulik | e3ace62 | 2018-06-07 10:51:02 +0200 | [diff] [blame] | 80 | common.retry(2,5){ |
| 81 | salt.enforceState(master, target, ['linux.system']) |
| 82 | } |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 83 | if (staticMgmtNet) { |
| 84 | salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| 85 | } |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 86 | salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 87 | salt.enforceState(master, target, ['salt.minion']) |
Jiri Broulik | 3740fb9 | 2018-04-27 11:52:38 +0200 | [diff] [blame] | 88 | salt.enforceState(master, target, ['linux.network.interface']) |
Jiri Broulik | 9453846 | 2018-05-11 15:45:13 +0200 | [diff] [blame] | 89 | sleep(5) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 90 | salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog']) |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 91 | sleep(5) |
Victor Ryzhenkin | f610c57 | 2018-05-15 15:22:52 +0400 | [diff] [blame] | 92 | |
| 93 | salt.fullRefresh(master, target) |
vrovachev | c4424a3 | 2018-03-15 17:35:57 +0400 | [diff] [blame] | 94 | salt.runSaltProcessStep(master, target, 'mine.update', [], null, true) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 95 | salt.enforceState(master, target, ['linux.network.host']) |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 96 | } |
| 97 | |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 98 | def installInfraKvm(master) { |
Dzmitry Stremkouski | 8a8d56b | 2018-05-01 12:20:04 +0200 | [diff] [blame] | 99 | def common = new com.mirantis.mk.Common() |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 100 | def salt = new com.mirantis.mk.Salt() |
Dzmitry Stremkouski | 5425d23 | 2018-06-07 00:46:00 +0200 | [diff] [blame] | 101 | def infra_compound = 'I@salt:control' |
Dzmitry Stremkouski | 8a8d56b | 2018-05-01 12:20:04 +0200 | [diff] [blame] | 102 | def minions = [] |
| 103 | def wait_timeout = 10 |
| 104 | def retries = wait_timeout * 30 |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 105 | |
Dzmitry Stremkouski | 5425d23 | 2018-06-07 00:46:00 +0200 | [diff] [blame] | 106 | salt.fullRefresh(master, 'I@linux:system') |
Richard Felkl | 286f25f | 2017-07-26 14:23:55 +0200 | [diff] [blame] | 107 | salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 108 | salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog']) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 109 | salt.enforceState(master, 'I@salt:control', 'libvirt') |
| 110 | salt.enforceState(master, 'I@salt:control', 'salt.control') |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 111 | |
Dzmitry Stremkouski | 5425d23 | 2018-06-07 00:46:00 +0200 | [diff] [blame] | 112 | common.infoMsg("Building minions list...") |
| 113 | if (salt.testTarget(master, infra_compound)) { |
| 114 | // Gathering minions |
| 115 | for ( infra_node in salt.getMinionsSorted(master, infra_compound) ) { |
| 116 | def pillar = salt.getPillar(master, infra_node, 'salt:control:cluster') |
| 117 | if ( !pillar['return'].isEmpty() ) { |
| 118 | for ( cluster in pillar['return'][0].values() ) { |
| 119 | def engine = cluster.values()[0]['engine'] |
| 120 | def domain = cluster.values()[0]['domain'] |
| 121 | def node = cluster.values()[0]['node'] |
| 122 | if ( engine == "virt" ) { |
| 123 | def nodes = node.values() |
| 124 | if ( !nodes.isEmpty() ) { |
| 125 | for ( vm in nodes ) { |
| 126 | if ( vm['name'] != null ) { |
| 127 | def vm_fqdn = vm['name'] + '.' + domain |
| 128 | if ( !minions.contains(vm_fqdn) ) { |
| 129 | minions.add(vm_fqdn) |
Dzmitry Stremkouski | 8a8d56b | 2018-05-01 12:20:04 +0200 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | } |
Dzmitry Stremkouski | 5425d23 | 2018-06-07 00:46:00 +0200 | [diff] [blame] | 138 | } |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 139 | |
Dzmitry Stremkouski | 5425d23 | 2018-06-07 00:46:00 +0200 | [diff] [blame] | 140 | def minions_compound = minions.join(' or ') |
| 141 | |
| 142 | common.infoMsg("Waiting for next minions to register within ${wait_timeout} minutes: " + minions_compound) |
| 143 | timeout(time: wait_timeout, unit: 'MINUTES') { |
Dzmitry Stremkouski | 8a8d56b | 2018-05-01 12:20:04 +0200 | [diff] [blame] | 144 | salt.minionsPresentFromList(master, 'I@salt:master', minions, true, null, true, retries, 1) |
Dzmitry Stremkouski | 5425d23 | 2018-06-07 00:46:00 +0200 | [diff] [blame] | 145 | } |
Dzmitry Stremkouski | 8a8d56b | 2018-05-01 12:20:04 +0200 | [diff] [blame] | 146 | |
Dzmitry Stremkouski | 5425d23 | 2018-06-07 00:46:00 +0200 | [diff] [blame] | 147 | common.infoMsg('Waiting for minions to respond') |
| 148 | timeout(time: wait_timeout, unit: 'MINUTES') { |
| 149 | salt.minionsReachable(master, 'I@salt:master', minions_compound) |
Dzmitry Stremkouski | 8a8d56b | 2018-05-01 12:20:04 +0200 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | common.infoMsg("All minions are up.") |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 153 | salt.fullRefresh(master, '* and not kvm*') |
Dzmitry Stremkouski | 8a8d56b | 2018-05-01 12:20:04 +0200 | [diff] [blame] | 154 | |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 155 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 156 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 157 | def installInfra(master) { |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 158 | def common = new com.mirantis.mk.Common() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 159 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 160 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 161 | // Install glusterfs |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 162 | if (salt.testTarget(master, 'I@glusterfs:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 163 | salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service') |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 164 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 165 | salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5) |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 166 | sleep(10) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 167 | salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status") |
Alexander Noskov | 93acac4 | 2017-06-20 17:55:55 +0200 | [diff] [blame] | 168 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 169 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 170 | // Ensure glusterfs clusters is ready |
| 171 | if (salt.testTarget(master, 'I@glusterfs:client')) { |
Martin Polreich | dde1214 | 2018-06-14 09:32:20 +0200 | [diff] [blame] | 172 | salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client', true, true, null, false, -1, 2) |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 173 | } |
| 174 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 175 | // Install galera |
Richard Felkl | c0f163e | 2017-07-27 15:11:12 +0200 | [diff] [blame] | 176 | if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 177 | salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2) |
Jakub Josef | 9994ea7 | 2018-03-05 13:23:07 +0100 | [diff] [blame] | 178 | salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 179 | |
| 180 | // Check galera status |
| 181 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 182 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 183 | // If galera is not enabled check if we need to install mysql:server |
| 184 | } else if (salt.testTarget(master, 'I@mysql:server')){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 185 | salt.enforceState(master, 'I@mysql:server', 'mysql.server') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 186 | if (salt.testTarget(master, 'I@mysql:client')){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 187 | salt.enforceState(master, 'I@mysql:client', 'mysql.client') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 188 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 189 | } |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 190 | installBackup(master, 'mysql') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 191 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 192 | // Install docker |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 193 | if (salt.testTarget(master, 'I@docker:host')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 194 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
Tomáš Kukrál | 0cf3ffb | 2017-09-03 10:18:18 +0200 | [diff] [blame] | 195 | salt.cmdRun(master, 'I@docker:host', 'docker ps') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 196 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 197 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 198 | // Install keepalived |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 199 | if (salt.testTarget(master, 'I@keepalived:cluster')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 200 | salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived') |
| 201 | salt.enforceState(master, 'I@keepalived:cluster', 'keepalived') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | // Install rabbitmq |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 205 | if (salt.testTarget(master, 'I@rabbitmq:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 206 | salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 207 | |
| 208 | // Check the rabbitmq status |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 209 | common.retry(3,5){ |
| 210 | salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status') |
| 211 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 212 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 213 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 214 | // Install haproxy |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 215 | if (salt.testTarget(master, 'I@haproxy:proxy')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 216 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 217 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 218 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
| 219 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 220 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 221 | // Install memcached |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 222 | if (salt.testTarget(master, 'I@memcached:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 223 | salt.enforceState(master, 'I@memcached:server', 'memcached') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | // Install etcd |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 227 | if (salt.testTarget(master, 'I@etcd:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 228 | salt.enforceState(master, 'I@etcd:server', 'etcd.server.service') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 229 | common.retry(3,5){ |
| 230 | salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health') |
| 231 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 232 | } |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 233 | |
| 234 | // Install redis |
| 235 | if (salt.testTarget(master, 'I@redis:server')) { |
| 236 | if (salt.testTarget(master, 'I@redis:cluster:role:master')) { |
| 237 | salt.enforceState(master, 'I@redis:cluster:role:master', 'redis') |
| 238 | } |
| 239 | salt.enforceState(master, 'I@redis:server', 'redis') |
| 240 | } |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 241 | installBackup(master, 'common') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | def installOpenstackInfra(master) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 245 | def common = new com.mirantis.mk.Common() |
| 246 | common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly") |
| 247 | installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 251 | def installOpenstackControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 252 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 253 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 254 | |
| 255 | // Install horizon dashboard |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 256 | if (salt.testTarget(master, 'I@horizon:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 257 | salt.enforceState(master, 'I@horizon:server', 'horizon') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 258 | } |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 259 | // Install sphinx server |
| 260 | if (salt.testTarget(master, 'I@sphinx:server')) { |
| 261 | salt.enforceState(master, 'I@sphinx:server', 'sphinx') |
| 262 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 263 | if (salt.testTarget(master, 'I@nginx:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 264 | salt.enforceState(master, 'I@nginx:server', 'salt.minion') |
| 265 | salt.enforceState(master, 'I@nginx:server', 'nginx') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 266 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 267 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 268 | // setup keystone service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 269 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 270 | salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server') |
| 271 | salt.enforceState(master, 'I@keystone:server', 'keystone.server') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 272 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 273 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 274 | // keystone:client must be called locally |
| 275 | //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| 276 | salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2']) |
| 277 | sleep(30) |
| 278 | } |
| 279 | if (salt.testTarget(master, 'I@keystone:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 280 | salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client') |
| 281 | salt.enforceState(master, 'I@keystone:client', 'keystone.client') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 282 | } |
| 283 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 284 | common.retry(3,5){ |
| 285 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list') |
| 286 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 287 | } |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 288 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 289 | // Install glance |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 290 | if (salt.testTarget(master, 'I@glance:server')) { |
| 291 | //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 292 | salt.enforceState(master, 'I@glance:server and *01*', 'glance.server') |
| 293 | salt.enforceState(master, 'I@glance:server', 'glance.server') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 294 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 295 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 296 | // Check glance service |
| 297 | if (salt.testTarget(master, 'I@glance:server')){ |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 298 | common.retry(3,5){ |
Oleg Iurchenko | 01410f2 | 2018-02-22 22:18:21 +0200 | [diff] [blame] | 299 | salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 300 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 301 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 302 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 303 | // Create glance resources |
| 304 | if (salt.testTarget(master, 'I@glance:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 305 | salt.enforceState(master, 'I@glance:client', 'glance.client') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 306 | } |
| 307 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 308 | // Install and check nova service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 309 | if (salt.testTarget(master, 'I@nova:controller')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 310 | // run on first node first |
| 311 | salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller') |
| 312 | salt.enforceState(master, 'I@nova:controller', 'nova.controller') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 313 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 314 | common.retry(3,5){ |
Oleg Iurchenko | 01410f2 | 2018-02-22 22:18:21 +0200 | [diff] [blame] | 315 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 316 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 317 | } |
| 318 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 319 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 320 | // Create nova resources |
| 321 | if (salt.testTarget(master, 'I@nova:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 322 | salt.enforceState(master, 'I@nova:client', 'nova.client') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 323 | } |
| 324 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 325 | // Install and check cinder service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 326 | if (salt.testTarget(master, 'I@cinder:controller')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 327 | // run on first node first |
| 328 | salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder') |
| 329 | salt.enforceState(master, 'I@cinder:controller', 'cinder') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 330 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 331 | common.retry(3,5){ |
Oleg Iurchenko | 01410f2 | 2018-02-22 22:18:21 +0200 | [diff] [blame] | 332 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 333 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 334 | } |
| 335 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 336 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 337 | // Install neutron service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 338 | if (salt.testTarget(master, 'I@neutron:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 339 | // run on first node first |
| 340 | salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server') |
| 341 | salt.enforceState(master, 'I@neutron:server', 'neutron.server') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 342 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 343 | common.retry(3,5){ |
Oleg Iurchenko | 01410f2 | 2018-02-22 22:18:21 +0200 | [diff] [blame] | 344 | salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 345 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 346 | } |
| 347 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 348 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 349 | // Install heat service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 350 | if (salt.testTarget(master, 'I@heat:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 351 | // run on first node first |
| 352 | salt.enforceState(master, 'I@heat:server and *01*', 'heat') |
| 353 | salt.enforceState(master, 'I@heat:server', 'heat') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 354 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 355 | common.retry(3,5){ |
Oleg Iurchenko | 01410f2 | 2018-02-22 22:18:21 +0200 | [diff] [blame] | 356 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 357 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 358 | } |
| 359 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 360 | |
| 361 | // Restart nova api |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 362 | if (salt.testTarget(master, 'I@nova:controller')) { |
| 363 | salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api']) |
| 364 | } |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 365 | |
| 366 | // Install ironic service |
| 367 | if (salt.testTarget(master, 'I@ironic:api')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 368 | salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api') |
| 369 | salt.enforceState(master, 'I@ironic:api', 'ironic.api') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 370 | } |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 371 | |
Vasyl Saienko | b7e4cdf | 2018-02-21 18:33:17 +0200 | [diff] [blame] | 372 | // Install manila service |
| 373 | if (salt.testTarget(master, 'I@manila:api')) { |
| 374 | salt.enforceState(master, 'I@manila:api and *01*', 'manila.api') |
| 375 | salt.enforceState(master, 'I@manila:api', 'manila.api') |
| 376 | } |
| 377 | if (salt.testTarget(master, 'I@manila:scheduler')) { |
| 378 | salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler') |
| 379 | } |
| 380 | |
Oleh Hryhorov | a070fd0 | 2018-03-15 14:47:52 +0200 | [diff] [blame] | 381 | // Install designate services |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 382 | if (salt.testTarget(master, 'I@designate:server:enabled')) { |
| 383 | if (salt.testTarget(master, 'I@designate:server:backend:bind9')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 384 | salt.enforceState(master, 'I@bind:server', 'bind.server') |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 385 | } |
| 386 | if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 387 | salt.enforceState(master, 'I@powerdns:server', 'powerdns.server') |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 388 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 389 | salt.enforceState(master, 'I@designate:server and *01*', 'designate.server') |
Oleh Hryhorov | a070fd0 | 2018-03-15 14:47:52 +0200 | [diff] [blame] | 390 | salt.enforceState(master, 'I@designate:server', 'designate') |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 391 | } |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 392 | |
| 393 | // Install octavia api service |
| 394 | if (salt.testTarget(master, 'I@octavia:api')) { |
Marcin Iwinski | b1ac98e | 2018-02-08 10:16:49 +0100 | [diff] [blame] | 395 | salt.enforceState(master, 'I@octavia:api and *01*', 'octavia') |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 396 | salt.enforceState(master, 'I@octavia:api', 'octavia') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 397 | } |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 398 | |
Oleg Iurchenko | d0898c9 | 2017-12-14 14:28:44 +0200 | [diff] [blame] | 399 | // Install DogTag server service |
| 400 | if (salt.testTarget(master, 'I@dogtag:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 401 | salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server') |
| 402 | salt.enforceState(master, 'I@dogtag:server', 'dogtag.server') |
Oleg Iurchenko | d0898c9 | 2017-12-14 14:28:44 +0200 | [diff] [blame] | 403 | } |
| 404 | |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 405 | // Install barbican server service |
| 406 | if (salt.testTarget(master, 'I@barbican:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 407 | salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server') |
| 408 | salt.enforceState(master, 'I@barbican:server', 'barbican.server') |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 409 | } |
| 410 | // Install barbican client |
| 411 | if (salt.testTarget(master, 'I@barbican:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 412 | salt.enforceState(master, 'I@barbican:client', 'barbican.client') |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 413 | } |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 414 | |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 415 | // Install gnocchi server |
| 416 | if (salt.testTarget(master, 'I@gnocchi:server')) { |
Mykyta Karpin | f60f02f | 2018-03-14 19:24:51 +0200 | [diff] [blame] | 417 | salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server') |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 418 | salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server') |
| 419 | } |
| 420 | |
| 421 | // Install gnocchi statsd |
| 422 | if (salt.testTarget(master, 'I@gnocchi:statsd')) { |
Mykyta Karpin | f60f02f | 2018-03-14 19:24:51 +0200 | [diff] [blame] | 423 | salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd') |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 424 | salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd') |
| 425 | } |
| 426 | |
| 427 | // Install panko server |
| 428 | if (salt.testTarget(master, 'I@panko:server')) { |
Mykyta Karpin | f60f02f | 2018-03-14 19:24:51 +0200 | [diff] [blame] | 429 | salt.enforceState(master, 'I@panko:server and *01*', 'panko') |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 430 | salt.enforceState(master, 'I@panko:server', 'panko') |
| 431 | } |
| 432 | |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 433 | // Install ceilometer server |
| 434 | if (salt.testTarget(master, 'I@ceilometer:server')) { |
Mykyta Karpin | f60f02f | 2018-03-14 19:24:51 +0200 | [diff] [blame] | 435 | salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer') |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 436 | salt.enforceState(master, 'I@ceilometer:server', 'ceilometer') |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | // Install aodh server |
| 440 | if (salt.testTarget(master, 'I@aodh:server')) { |
Mykyta Karpin | f60f02f | 2018-03-14 19:24:51 +0200 | [diff] [blame] | 441 | salt.enforceState(master, 'I@aodh:server and *01*', 'aodh') |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 442 | salt.enforceState(master, 'I@aodh:server', 'aodh') |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 443 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 447 | def installIronicConductor(master){ |
| 448 | def salt = new com.mirantis.mk.Salt() |
| 449 | |
| 450 | if (salt.testTarget(master, 'I@ironic:conductor')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 451 | salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor') |
| 452 | salt.enforceState(master, 'I@ironic:conductor', 'apache') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 453 | } |
| 454 | if (salt.testTarget(master, 'I@tftpd_hpa:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 455 | salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | if (salt.testTarget(master, 'I@nova:compute')) { |
| 459 | salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute']) |
| 460 | } |
| 461 | |
| 462 | if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 463 | salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 464 | } |
| 465 | if (salt.testTarget(master, 'I@ironic:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 466 | salt.enforceState(master, 'I@ironic:client', 'ironic.client') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 467 | } |
| 468 | } |
| 469 | |
Vasyl Saienko | b7e4cdf | 2018-02-21 18:33:17 +0200 | [diff] [blame] | 470 | def installManilaShare(master){ |
| 471 | def salt = new com.mirantis.mk.Salt() |
| 472 | |
| 473 | if (salt.testTarget(master, 'I@manila:share')) { |
| 474 | salt.enforceState(master, 'I@manila:share', 'manila.share') |
| 475 | } |
| 476 | if (salt.testTarget(master, 'I@manila:data')) { |
| 477 | salt.enforceState(master, 'I@manila:data', 'manila.data') |
| 478 | } |
| 479 | |
| 480 | if (salt.testTarget(master, 'I@manila:client')) { |
| 481 | salt.enforceState(master, 'I@manila:client', 'manila.client') |
| 482 | } |
| 483 | } |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 484 | |
| 485 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 486 | def installOpenstackNetwork(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 487 | def salt = new com.mirantis.mk.Salt() |
Oleksii Grudev | c4a485e | 2018-04-20 14:25:03 +0300 | [diff] [blame] | 488 | //run full neutron state on neutron.gateway - this will install |
| 489 | //neutron agents in addition to neutron server. Once neutron agents |
| 490 | //are up neutron resources can be created without hitting the situation when neutron resources are created |
| 491 | //prior to neutron agents which results in creating ports in non-usable state |
| 492 | if (salt.testTarget(master, 'I@neutron:gateway')) { |
| 493 | salt.enforceState(master, 'I@neutron:gateway', 'neutron') |
| 494 | } |
| 495 | |
| 496 | // Create neutron resources - this step was moved here to ensure that |
| 497 | //neutron resources are created after neutron agens are up. In this case neutron ports will be in |
| 498 | //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249 |
| 499 | if (salt.testTarget(master, 'I@neutron:client')) { |
| 500 | salt.enforceState(master, 'I@neutron:client', 'neutron.client') |
| 501 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 502 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 503 | salt.enforceHighstate(master, 'I@neutron:gateway') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 504 | |
| 505 | // install octavia manager services |
| 506 | if (salt.testTarget(master, 'I@octavia:manager')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 507 | salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*']) |
| 508 | salt.enforceState(master, 'I@octavia:manager', 'octavia') |
| 509 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca') |
| 510 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 511 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | |
| 515 | def installOpenstackCompute(master) { |
| 516 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 517 | // Configure compute nodes |
Dzmitry Stremkouski | feb8ce9 | 2018-03-21 18:03:28 +0100 | [diff] [blame] | 518 | def compute_compound = 'I@nova:compute' |
| 519 | if (salt.testTarget(master, compute_compound)) { |
| 520 | // In case if infrastructure nodes are used as nova computes too |
| 521 | def gluster_compound = 'I@glusterfs:server' |
Dzmitry Stremkouski | 7eca99d | 2018-04-25 18:44:26 +0200 | [diff] [blame] | 522 | def salt_ca_compound = 'I@salt:minion:ca:salt_master_ca' |
| 523 | // Enforce highstate asynchronous only on compute nodes which are not glusterfs and not salt ca servers |
Oleh Hryhorov | 73f9fa2 | 2018-05-02 17:36:58 +0300 | [diff] [blame] | 524 | def hightstateTarget = "${compute_compound} and not ${gluster_compound} and not ${salt_ca_compound}" |
| 525 | if (salt.testTarget(master, hightstateTarget)) { |
| 526 | retry(2) { |
| 527 | salt.enforceHighstateWithExclude(master, hightstateTarget, 'opencontrail.client') |
| 528 | } |
Dzmitry Stremkouski | 7eca99d | 2018-04-25 18:44:26 +0200 | [diff] [blame] | 529 | } |
| 530 | // Iterate through salt ca servers and check if they have compute role |
| 531 | // TODO: switch to batch once salt 2017.7+ would be used |
| 532 | for ( target in salt.getMinionsSorted(master, salt_ca_compound) ) { |
| 533 | for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) { |
| 534 | if ( target == cmp_target ) { |
| 535 | // Enforce highstate one by one on salt ca servers which are compute nodes |
| 536 | retry(2) { |
| 537 | salt.enforceHighstateWithExclude(master, target, 'opencontrail.client') |
| 538 | } |
| 539 | } |
| 540 | } |
Dzmitry Stremkouski | feb8ce9 | 2018-03-21 18:03:28 +0100 | [diff] [blame] | 541 | } |
| 542 | // Iterate through glusterfs servers and check if they have compute role |
| 543 | // TODO: switch to batch once salt 2017.7+ would be used |
| 544 | for ( target in salt.getMinionsSorted(master, gluster_compound) ) { |
| 545 | for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) { |
| 546 | if ( target == cmp_target ) { |
| 547 | // Enforce highstate one by one on glusterfs servers which are compute nodes |
| 548 | retry(2) { |
| 549 | salt.enforceHighstateWithExclude(master, target, 'opencontrail.client') |
| 550 | } |
| 551 | } |
| 552 | } |
Sergio Lystopad | cd5b277 | 2018-02-09 14:37:10 +0200 | [diff] [blame] | 553 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 554 | } |
Vasyl Saienko | 51144e4 | 2018-06-19 09:30:30 +0300 | [diff] [blame^] | 555 | |
| 556 | // Run nova:controller to map cmp with cells |
| 557 | if (salt.testTarget(master, 'I@nova:controller')) { |
| 558 | salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller') |
| 559 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | |
| 563 | def installContrailNetwork(master) { |
Martin Polreich | fc9854c | 2017-06-30 11:17:36 +0200 | [diff] [blame] | 564 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 565 | def salt = new com.mirantis.mk.Salt() |
| 566 | |
| 567 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 568 | // Install opencontrail database services |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 569 | salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database') |
| 570 | salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 571 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 572 | // Install opencontrail control services |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 573 | salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client") |
| 574 | salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client") |
| 575 | salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client") |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 576 | |
Marek Celoud | 443fb64 | 2017-11-22 15:07:12 +0100 | [diff] [blame] | 577 | if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 578 | salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client') |
Marek Celoud | 443fb64 | 2017-11-22 15:07:12 +0100 | [diff] [blame] | 579 | } |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 580 | installBackup(master, 'contrail') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 584 | def installContrailCompute(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 585 | def salt = new com.mirantis.mk.Salt() |
vrovachev | 32f7f54 | 2017-08-25 16:17:25 +0400 | [diff] [blame] | 586 | def common = new com.mirantis.mk.Common() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 587 | // Configure compute nodes |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 588 | // Provision opencontrail control services |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 589 | salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 590 | // Provision opencontrail virtual routers |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 591 | |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 592 | // Generate script /usr/lib/contrail/if-vhost0 for up vhost0 |
Sergio Lystopad | cd5b277 | 2018-02-09 14:37:10 +0200 | [diff] [blame] | 593 | if (salt.testTarget(master, 'I@opencontrail:compute')) { |
| 594 | salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client") |
| 595 | } |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 596 | |
Sergio Lystopad | cd5b277 | 2018-02-09 14:37:10 +0200 | [diff] [blame] | 597 | if (salt.testTarget(master, 'I@nova:compute')) { |
| 598 | salt.cmdRun(master, 'I@nova:compute', 'exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || sleep 5 && reboot & "', false) |
| 599 | } |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 600 | |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 601 | sleep(300) |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 602 | if (salt.testTarget(master, 'I@opencontrail:compute')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 603 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client') |
| 604 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail') |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 605 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 609 | def installKubernetesInfra(master) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 610 | def common = new com.mirantis.mk.Common() |
| 611 | common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly") |
| 612 | installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | |
Tomáš Kukrál | c1a1bbc | 2017-04-28 21:16:25 +0200 | [diff] [blame] | 616 | def installKubernetesControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 617 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 618 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 619 | // Install Kubernetes pool and Calico |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 620 | salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons') |
| 621 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 622 | |
Marek Celoud | 029391c | 2017-11-14 10:06:18 +0100 | [diff] [blame] | 623 | if (salt.testTarget(master, 'I@etcd:server:setup')) { |
| 624 | // Setup etcd server |
| 625 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup') |
| 626 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 627 | |
Victor Ryzhenkin | fb5d1b5 | 2018-05-22 18:49:26 +0400 | [diff] [blame] | 628 | // Run k8s master at *01* to simplify namespaces creation |
| 629 | salt.enforceStateWithExclude(master, 'I@kubernetes:master and *01*', "kubernetes.master", "kubernetes.master.setup") |
| 630 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 631 | // Run k8s without master.setup |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 632 | salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup") |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 633 | |
| 634 | // Run k8s master setup |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 635 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 636 | |
| 637 | // Restart kubelet |
| 638 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
| 639 | } |
| 640 | |
| 641 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 642 | def installKubernetesCompute(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 643 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 644 | salt.fullRefresh(master, "*") |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 645 | |
| 646 | // Bootstrap all nodes |
| 647 | salt.enforceState(master, 'I@kubernetes:pool', 'linux') |
| 648 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion') |
| 649 | salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp']) |
| 650 | |
| 651 | // Create and distribute SSL certificates for services using salt state |
| 652 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert') |
| 653 | |
| 654 | // Install docker |
| 655 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
| 656 | |
| 657 | // Install Kubernetes and Calico |
| 658 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
| 659 | |
Yuriy Taraday | ab564d7 | 2017-10-11 15:14:35 +0400 | [diff] [blame] | 660 | // Install Tiller and all configured releases |
| 661 | if (salt.testTarget(master, 'I@helm:client')) { |
| 662 | salt.enforceState(master, 'I@helm:client', 'helm') |
| 663 | } |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 667 | def installDockerSwarm(master) { |
| 668 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 669 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 670 | //Install and Configure Docker |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 671 | salt.enforceState(master, 'I@docker:swarm', 'docker.host') |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 672 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm') |
| 673 | salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains') |
| 674 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update') |
| 675 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 676 | sleep(5) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 677 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm') |
| 678 | salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 679 | sleep(10) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 680 | salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 681 | } |
| 682 | |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 683 | |
| 684 | def installCicd(master) { |
| 685 | def salt = new com.mirantis.mk.Salt() |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 686 | def common = new com.mirantis.mk.Common() |
| 687 | def gerrit_compound = 'I@gerrit:client and ci*' |
| 688 | def jenkins_compound = 'I@jenkins:client and ci*' |
| 689 | |
| 690 | salt.fullRefresh(master, gerrit_compound) |
| 691 | salt.fullRefresh(master, jenkins_compound) |
Richard Felkl | 9d2cd92 | 2017-11-03 11:49:32 +0100 | [diff] [blame] | 692 | |
Richard Felkl | 6de1676 | 2017-11-20 11:42:28 +0100 | [diff] [blame] | 693 | salt.enforceState(master, 'I@docker:swarm:role:master and I@jenkins:client', 'docker.client', true, true, null, false, -1, 2) |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 694 | |
| 695 | // API timeout in minutes |
| 696 | def wait_timeout = 10 |
| 697 | |
| 698 | // Gerrit |
| 699 | def gerrit_master_url = salt.getPillar(master, gerrit_compound, '_param:gerrit_master_url') |
| 700 | |
| 701 | if(!gerrit_master_url['return'].isEmpty()) { |
| 702 | gerrit_master_url = gerrit_master_url['return'][0].values()[0] |
| 703 | } else { |
| 704 | gerrit_master_url = '' |
| 705 | } |
| 706 | |
| 707 | if (gerrit_master_url != '') { |
| 708 | common.infoMsg('Gerrit master url "' + gerrit_master_url + '" retrieved at _param:gerrit_master_url') |
| 709 | } else { |
| 710 | |
| 711 | common.infoMsg('Gerrit master url could not be retrieved at _param:gerrit_master_url. Falling back to gerrit pillar') |
| 712 | |
| 713 | def gerrit_host |
| 714 | def gerrit_http_port |
| 715 | def gerrit_http_scheme |
| 716 | |
| 717 | def host_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:host') |
| 718 | gerrit_host = salt.getReturnValues(host_pillar) |
| 719 | |
| 720 | def port_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:http_port') |
| 721 | gerrit_http_port = salt.getReturnValues(port_pillar) |
| 722 | |
| 723 | def scheme_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:protocol') |
| 724 | gerrit_http_scheme = salt.getReturnValues(scheme_pillar) |
| 725 | |
| 726 | gerrit_master_url = gerrit_http_scheme + '://' + gerrit_host + ':' + gerrit_http_port |
| 727 | |
| 728 | } |
| 729 | |
| 730 | timeout(wait_timeout) { |
| 731 | common.infoMsg('Waiting for Gerrit to come up..') |
Dzmitry Stremkouski | 5440ffa | 2018-05-31 12:00:02 +0200 | [diff] [blame] | 732 | def check_gerrit_cmd = 'while true; do curl -sI -m 3 -o /dev/null -w' + " '" + '%{http_code}' + "' " + gerrit_master_url + '/ | grep 200 && break || sleep 1; done' |
| 733 | salt.cmdRun(master, gerrit_compound, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_gerrit_cmd + '"') |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | // Jenkins |
| 737 | def jenkins_master_url_pillar = salt.getPillar(master, jenkins_compound, '_param:jenkins_master_url') |
| 738 | jenkins_master_url = salt.getReturnValues(jenkins_master_url_pillar) |
| 739 | |
| 740 | timeout(wait_timeout) { |
| 741 | common.infoMsg('Waiting for Jenkins to come up..') |
Dzmitry Stremkouski | 5440ffa | 2018-05-31 12:00:02 +0200 | [diff] [blame] | 742 | def check_jenkins_cmd = 'while true; do curl -sI -m 3 -o /dev/null -w' + " '" + '%{http_code}' + "' " + jenkins_master_url + '/whoAmI/ | grep 200 && break || sleep 1; done' |
| 743 | salt.cmdRun(master, jenkins_compound, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_jenkins_cmd + '"') |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 744 | } |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 745 | |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 746 | if (salt.testTarget(master, 'I@openldap:client')) { |
| 747 | salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2) |
| 748 | } |
Richard Felkl | b6fdec9 | 2017-09-26 10:52:36 +0200 | [diff] [blame] | 749 | |
| 750 | if (salt.testTarget(master, 'I@python:environment')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 751 | salt.enforceState(master, 'I@python:environment', 'python') |
Richard Felkl | b6fdec9 | 2017-09-26 10:52:36 +0200 | [diff] [blame] | 752 | } |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 753 | |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 754 | withEnv(['ASK_ON_ERROR=false']){ |
| 755 | retry(2){ |
| 756 | try{ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 757 | salt.enforceState(master, 'I@gerrit:client', 'gerrit') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 758 | }catch(e){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 759 | salt.fullRefresh(master, 'I@gerrit:client') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 760 | throw e //rethrow for retry handler |
| 761 | } |
| 762 | } |
| 763 | retry(2){ |
| 764 | try{ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 765 | salt.enforceState(master, 'I@jenkins:client', 'jenkins') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 766 | }catch(e){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 767 | salt.fullRefresh(master, 'I@jenkins:client') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 768 | throw e //rethrow for retry handler |
| 769 | } |
| 770 | } |
| 771 | } |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 775 | def installStacklight(master) { |
| 776 | def common = new com.mirantis.mk.Common() |
| 777 | def salt = new com.mirantis.mk.Salt() |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 778 | def retries_wait = 20 |
| 779 | def retries = 15 |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 780 | |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 781 | // Install core services for K8S environments: |
| 782 | // HAProxy, Nginx and lusterFS clients |
| 783 | // In case of OpenStack, those are already installed |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 784 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 785 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
| 786 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 787 | |
| 788 | if (salt.testTarget(master, 'I@nginx:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 789 | salt.enforceState(master, 'I@nginx:server', 'nginx') |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | if (salt.testTarget(master, 'I@glusterfs:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 793 | salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client') |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 794 | } |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 795 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 796 | |
Dmitry Kalashnik | 69ecb78 | 2018-05-21 17:36:50 +0400 | [diff] [blame] | 797 | // Install MongoDB for Alerta |
| 798 | if (salt.testTarget(master, 'I@mongodb:server')) { |
Ildar Svetlov | 829f94a | 2018-06-05 17:57:08 +0400 | [diff] [blame] | 799 | salt.enforceState(master, 'I@mongodb:server', 'mongodb.server') |
| 800 | |
| 801 | // Initialize mongodb replica set |
| 802 | common.retry(5,20){ |
| 803 | salt.enforceState(master, 'I@mongodb:server', 'mongodb.cluster') |
| 804 | } |
Dmitry Kalashnik | 69ecb78 | 2018-05-21 17:36:50 +0400 | [diff] [blame] | 805 | } |
| 806 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 807 | //Install Telegraf |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 808 | salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 809 | |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 810 | // Install Prometheus exporters |
| 811 | if (salt.testTarget(master, 'I@prometheus:exporters')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 812 | salt.enforceState(master, 'I@prometheus:exporters', 'prometheus') |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 813 | } |
| 814 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 815 | //Install Elasticsearch and Kibana |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 816 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server') |
| 817 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server') |
| 818 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server') |
| 819 | salt.enforceState(master, 'I@kibana:server', 'kibana.server') |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 820 | |
| 821 | // Check ES health cluster status |
| 822 | def pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host') |
| 823 | def elasticsearch_vip |
| 824 | if(!pillar['return'].isEmpty()) { |
| 825 | elasticsearch_vip = pillar['return'][0].values()[0] |
| 826 | } else { |
| 827 | common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| 828 | } |
| 829 | pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:port') |
| 830 | def elasticsearch_port |
| 831 | if(!pillar['return'].isEmpty()) { |
| 832 | elasticsearch_port = pillar['return'][0].values()[0] |
| 833 | } else { |
| 834 | common.errorMsg('[ERROR] Elasticsearch VIP port could not be retrieved') |
| 835 | } |
| 836 | common.retry(retries,retries_wait) { |
| 837 | common.infoMsg('Waiting for Elasticsearch to become green..') |
| 838 | salt.cmdRun(master, 'I@elasticsearch:client', "curl -sf ${elasticsearch_vip}:${elasticsearch_port}/_cat/health | awk '{print \$4}' | grep green") |
| 839 | } |
| 840 | |
Mateusz Matuszkowiak | ae2ccbc | 2018-06-07 09:18:57 +0200 | [diff] [blame] | 841 | common.retry(retries,retries_wait) { |
Mateusz Matuszkowiak | b46fbc1 | 2018-06-08 10:52:15 +0200 | [diff] [blame] | 842 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client') |
Mateusz Matuszkowiak | ae2ccbc | 2018-06-07 09:18:57 +0200 | [diff] [blame] | 843 | } |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 844 | |
Mateusz Matuszkowiak | ae2ccbc | 2018-06-07 09:18:57 +0200 | [diff] [blame] | 845 | common.retry(retries,retries_wait) { |
Mateusz Matuszkowiak | b46fbc1 | 2018-06-08 10:52:15 +0200 | [diff] [blame] | 846 | salt.enforceState(master, 'I@kibana:client', 'kibana.client') |
Mateusz Matuszkowiak | ae2ccbc | 2018-06-07 09:18:57 +0200 | [diff] [blame] | 847 | } |
Dmitry Kalashnik | 53feda7 | 2018-03-16 16:06:10 +0400 | [diff] [blame] | 848 | |
| 849 | //Install InfluxDB |
| 850 | if (salt.testTarget(master, 'I@influxdb:server')) { |
| 851 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb') |
| 852 | salt.enforceState(master, 'I@influxdb:server', 'influxdb') |
| 853 | } |
| 854 | |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 855 | // Install service for the log collection |
| 856 | if (salt.testTarget(master, 'I@fluentd:agent')) { |
| 857 | salt.enforceState(master, 'I@fluentd:agent', 'fluentd') |
| 858 | } else { |
| 859 | salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector') |
| 860 | } |
Simon Pasquier | 6301ddd | 2017-09-05 11:56:58 +0200 | [diff] [blame] | 861 | |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 862 | // Install heka ceilometer collector |
| 863 | if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 864 | salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector') |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 865 | salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true) |
| 866 | } |
| 867 | |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 868 | // Install galera |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 869 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 870 | salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2) |
Jakub Josef | 9994ea7 | 2018-03-05 13:23:07 +0100 | [diff] [blame] | 871 | salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2) |
Martin Polreich | 406f646 | 2017-07-11 11:33:42 +0000 | [diff] [blame] | 872 | |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 873 | // Check galera status |
| 874 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 875 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
| 876 | } |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 877 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 878 | //Collect Grains |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 879 | salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains') |
| 880 | salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules') |
| 881 | salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 882 | sleep(5) |
| 883 | |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 884 | // Configure Prometheus in Docker Swarm |
Oleg Basov | 162dd8a | 2018-03-13 01:27:50 +0100 | [diff] [blame] | 885 | salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus') |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 886 | |
Ildar Svetlov | 0eec97d | 2018-02-15 10:06:40 +0400 | [diff] [blame] | 887 | //Configure Remote Collector in Docker Swarm for Openstack deployments |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 888 | if (!common.checkContains('STACK_INSTALL', 'k8s')) { |
Ildar Svetlov | 0eec97d | 2018-02-15 10:06:40 +0400 | [diff] [blame] | 889 | salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false) |
Martin Polreich | 8017f45 | 2017-08-21 16:01:42 +0200 | [diff] [blame] | 890 | } |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 891 | |
Ildar Svetlov | 225fb6c | 2018-06-06 14:59:31 +0400 | [diff] [blame] | 892 | // Launch containers |
| 893 | salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client') |
| 894 | salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps') |
| 895 | |
| 896 | //Install Prometheus LTS |
| 897 | if (salt.testTarget(master, 'I@prometheus:relay')) { |
| 898 | salt.enforceState(master, 'I@prometheus:relay', 'prometheus') |
| 899 | } |
| 900 | |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 901 | // Install sphinx server |
| 902 | if (salt.testTarget(master, 'I@sphinx:server')) { |
| 903 | salt.enforceState(master, 'I@sphinx:server', 'sphinx') |
| 904 | } |
| 905 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 906 | //Configure Grafana |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 907 | pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 908 | common.prettyPrint(pillar) |
Martin Polreich | 595baef | 2017-07-04 16:11:04 +0200 | [diff] [blame] | 909 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 910 | def stacklight_vip |
| 911 | if(!pillar['return'].isEmpty()) { |
| 912 | stacklight_vip = pillar['return'][0].values()[0] |
| 913 | } else { |
| 914 | common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved') |
| 915 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 916 | |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 917 | common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start") |
Martin Polreich | bd7ad22 | 2017-07-06 12:53:51 +0200 | [diff] [blame] | 918 | sleep(120) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 919 | salt.enforceState(master, 'I@grafana:client', 'grafana.client') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | def installStacklightv1Control(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 923 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 924 | |
| 925 | // infra install |
| 926 | // Install the StackLight backends |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 927 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server') |
| 928 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 929 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 930 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb') |
| 931 | salt.enforceState(master, 'I@influxdb:server', 'influxdb') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 932 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 933 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server') |
| 934 | salt.enforceState(master, 'I@kibana:server', 'kibana.server') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 935 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 936 | salt.enforceState(master, '*01* and I@grafana:server','grafana.server') |
| 937 | salt.enforceState(master, 'I@grafana:server','grafana.server') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 938 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 939 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 940 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
| 941 | |
| 942 | switch (alarming_service) { |
| 943 | case 'sensu': |
| 944 | // Update Sensu |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 945 | salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq') |
| 946 | salt.enforceState(master, 'I@redis:cluster:role:master', 'redis') |
| 947 | salt.enforceState(master, 'I@redis:server', 'redis') |
| 948 | salt.enforceState(master, 'I@sensu:server', 'sensu') |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 949 | default: |
| 950 | // Update Nagios |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 951 | salt.enforceState(master, 'I@nagios:server', 'nagios.server') |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 952 | // Stop the Nagios service because the package starts it by default and it will |
| 953 | // started later only on the node holding the VIP address |
| 954 | salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true) |
| 955 | } |
| 956 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 957 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service') |
| 958 | salt.enforceState(master, 'I@kibana:client', 'kibana.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 959 | |
| 960 | sleep(10) |
| 961 | } |
| 962 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 963 | def installStacklightv1Client(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 964 | def salt = new com.mirantis.mk.Salt() |
| 965 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 966 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 967 | salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 968 | // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 969 | salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 970 | // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
| 971 | |
| 972 | // Install collectd, heka and sensu services on the nodes, this will also |
| 973 | // generate the metadata that goes into the grains and eventually into Salt Mine |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 974 | salt.enforceState(master, '*', 'collectd') |
| 975 | salt.enforceState(master, '*', 'salt.minion') |
| 976 | salt.enforceState(master, '*', 'heka') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 977 | |
| 978 | // Gather the Grafana metadata as grains |
| 979 | salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true) |
| 980 | |
| 981 | // Update Salt Mine |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 982 | salt.enforceState(master, '*', 'salt.minion.grains') |
| 983 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules') |
| 984 | salt.runSaltProcessStep(master, '*', 'mine.update') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 985 | |
| 986 | sleep(5) |
| 987 | |
| 988 | // Update Heka |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 989 | salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 990 | |
| 991 | // Update collectd |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 992 | salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 993 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 994 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 995 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 996 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 997 | switch (alarming_service) { |
| 998 | case 'sensu': |
| 999 | // Update Sensu |
| 1000 | // TODO for stacklight team, should be fixed in model |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1001 | salt.enforceState(master, 'I@sensu:client', 'sensu') |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 1002 | default: |
| 1003 | break |
| 1004 | // Default is nagios, and was enforced in installStacklightControl() |
| 1005 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1006 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1007 | salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1008 | // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 1009 | |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 1010 | // Finalize the configuration of Grafana (add the dashboards...) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1011 | salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client') |
| 1012 | salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client') |
| 1013 | salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client') |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 1014 | // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
| 1015 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1016 | // Get the StackLight monitoring VIP addres |
| 1017 | //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 1018 | //vip=${vip:=172.16.10.253} |
| 1019 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Jakub Josef | bceaa32 | 2017-06-13 18:28:27 +0200 | [diff] [blame] | 1020 | common.prettyPrint(pillar) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1021 | def stacklight_vip = pillar['return'][0].values()[0] |
| 1022 | |
| 1023 | if (stacklight_vip) { |
| 1024 | // (re)Start manually the services that are bound to the monitoring VIP |
| 1025 | common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1026 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd']) |
| 1027 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector']) |
| 1028 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator']) |
| 1029 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1030 | } else { |
| 1031 | throw new Exception("Missing stacklight_vip") |
| 1032 | } |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 1033 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1034 | |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1035 | // |
| 1036 | // backups |
| 1037 | // |
| 1038 | |
| 1039 | def installBackup(master, component='common') { |
| 1040 | def salt = new com.mirantis.mk.Salt() |
| 1041 | if (component == 'common') { |
| 1042 | // Install Backupninja |
| 1043 | if (salt.testTarget(master, 'I@backupninja:client')) { |
| 1044 | salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains') |
| 1045 | salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains') |
Jiri Broulik | 9e578da | 2018-03-01 13:15:53 +0100 | [diff] [blame] | 1046 | salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1047 | salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update') |
Jiri Broulik | be6898c | 2018-03-01 13:01:48 +0100 | [diff] [blame] | 1048 | salt.enforceState(master, 'I@backupninja:client', 'backupninja') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1049 | } |
| 1050 | if (salt.testTarget(master, 'I@backupninja:server')) { |
Jiri Broulik | 9e578da | 2018-03-01 13:15:53 +0100 | [diff] [blame] | 1051 | salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains') |
Jiri Broulik | be6898c | 2018-03-01 13:01:48 +0100 | [diff] [blame] | 1052 | salt.enforceState(master, 'I@backupninja:server', 'backupninja') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1053 | } |
| 1054 | } else if (component == 'mysql') { |
| 1055 | // Install Xtrabackup |
| 1056 | if (salt.testTarget(master, 'I@xtrabackup:client')) { |
| 1057 | salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains') |
| 1058 | salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains') |
Jiri Broulik | 9e578da | 2018-03-01 13:15:53 +0100 | [diff] [blame] | 1059 | salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1060 | salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update') |
| 1061 | salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup') |
| 1062 | } |
| 1063 | if (salt.testTarget(master, 'I@xtrabackup:server')) { |
| 1064 | salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup') |
| 1065 | } |
| 1066 | } else if (component == 'contrail') { |
| 1067 | |
| 1068 | // Install Cassandra backup |
| 1069 | if (salt.testTarget(master, 'I@cassandra:backup:client')) { |
| 1070 | salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains') |
| 1071 | salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains') |
Jiri Broulik | 9e578da | 2018-03-01 13:15:53 +0100 | [diff] [blame] | 1072 | salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1073 | salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update') |
| 1074 | salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup') |
| 1075 | } |
| 1076 | if (salt.testTarget(master, 'I@cassandra:backup:server')) { |
| 1077 | salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup') |
| 1078 | } |
| 1079 | // Install Zookeeper backup |
| 1080 | if (salt.testTarget(master, 'I@zookeeper:backup:client')) { |
| 1081 | salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains') |
| 1082 | salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains') |
Jiri Broulik | 9e578da | 2018-03-01 13:15:53 +0100 | [diff] [blame] | 1083 | salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1084 | salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update') |
| 1085 | salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup') |
| 1086 | } |
| 1087 | if (salt.testTarget(master, 'I@zookeeper:backup:server')) { |
| 1088 | salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup') |
| 1089 | } |
| 1090 | } else if (component == 'ceph') { |
| 1091 | // Install Ceph backup |
| 1092 | if (salt.testTarget(master, 'I@ceph:backup:client')) { |
| 1093 | salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains') |
| 1094 | salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains') |
Jiri Broulik | 9e578da | 2018-03-01 13:15:53 +0100 | [diff] [blame] | 1095 | salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1096 | salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update') |
Jiri Broulik | be6898c | 2018-03-01 13:01:48 +0100 | [diff] [blame] | 1097 | salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1098 | } |
| 1099 | if (salt.testTarget(master, 'I@ceph:backup:server')) { |
Jiri Broulik | be6898c | 2018-03-01 13:01:48 +0100 | [diff] [blame] | 1100 | salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1105 | |
| 1106 | // |
| 1107 | // Ceph |
| 1108 | // |
| 1109 | |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 1110 | def installCephMon(master, target='I@ceph:mon') { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1111 | def salt = new com.mirantis.mk.Salt() |
| 1112 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1113 | salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains') |
Jiri Broulik | bfc234f | 2017-10-17 15:45:38 +0200 | [diff] [blame] | 1114 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1115 | // generate keyrings |
| 1116 | if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1117 | salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon') |
| 1118 | salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains') |
| 1119 | salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update') |
Jiri Broulik | 3c75a6d | 2017-10-06 18:44:37 +0200 | [diff] [blame] | 1120 | sleep(5) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1121 | } |
Ondrej Smola | fd5c235 | 2017-08-11 14:25:39 +0200 | [diff] [blame] | 1122 | // install Ceph Mons |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1123 | salt.enforceState(master, target, 'ceph.mon') |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1124 | if (salt.testTarget(master, 'I@ceph:mgr')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1125 | salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr') |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1126 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1127 | } |
| 1128 | |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 1129 | def installCephOsd(master, target='I@ceph:osd', setup=true) { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1130 | def salt = new com.mirantis.mk.Salt() |
| 1131 | |
| 1132 | // install Ceph OSDs |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1133 | salt.enforceState(master, target, 'ceph.osd') |
| 1134 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains') |
| 1135 | salt.enforceState(master, target, 'ceph.osd.custom') |
| 1136 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains') |
| 1137 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1138 | installBackup(master, 'ceph') |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 1139 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1140 | // setup pools, keyrings and maybe crush |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 1141 | if (salt.testTarget(master, 'I@ceph:setup') && setup) { |
Jiri Broulik | 07f8de7 | 2017-10-09 14:12:17 +0200 | [diff] [blame] | 1142 | sleep(5) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1143 | salt.enforceState(master, 'I@ceph:setup', 'ceph.setup') |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 1144 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1145 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 1146 | |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 1147 | def installCephClient(master) { |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 1148 | def salt = new com.mirantis.mk.Salt() |
| 1149 | |
| 1150 | // install Ceph Radosgw |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 1151 | if (salt.testTarget(master, 'I@ceph:radosgw')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1152 | salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains') |
| 1153 | salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw') |
Alexander Noskov | 229035f | 2017-12-06 00:10:20 +0400 | [diff] [blame] | 1154 | } |
| 1155 | // setup Keystone service and endpoints for swift or / and S3 |
| 1156 | if (salt.testTarget(master, 'I@keystone:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1157 | salt.enforceState(master, 'I@keystone:client', 'keystone.client') |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 1158 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 1159 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1160 | |
| 1161 | def connectCeph(master) { |
| 1162 | def salt = new com.mirantis.mk.Salt() |
| 1163 | |
| 1164 | // connect Ceph to the env |
| 1165 | if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1166 | salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance']) |
Dmitry Ukov | 8a344b7 | 2018-05-17 17:05:17 +0400 | [diff] [blame] | 1167 | salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api']) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1168 | } |
| 1169 | if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1170 | salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder']) |
Dmitry Ukov | 8a344b7 | 2018-05-17 17:05:17 +0400 | [diff] [blame] | 1171 | salt.runSaltProcessStep(master, 'I@ceph:common and I@cinder:controller', 'service.restart', ['cinder-volume']) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1172 | } |
| 1173 | if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1174 | salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring']) |
| 1175 | salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains') |
| 1176 | salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova']) |
Dmitry Ukov | 8a344b7 | 2018-05-17 17:05:17 +0400 | [diff] [blame] | 1177 | salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'service.restart', ['nova-compute']) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1178 | } |
| 1179 | } |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1180 | |
| 1181 | def installOssInfra(master) { |
| 1182 | def common = new com.mirantis.mk.Common() |
| 1183 | def salt = new com.mirantis.mk.Salt() |
| 1184 | |
Mikhail Ivanov | 788996c | 2017-12-15 14:28:57 +0400 | [diff] [blame] | 1185 | if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) { |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1186 | def orchestrate = new com.mirantis.mk.Orchestrate() |
| 1187 | orchestrate.installInfra(master) |
| 1188 | } |
| 1189 | |
| 1190 | if (salt.testTarget(master, 'I@devops_portal:config')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1191 | salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config') |
| 1192 | salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh']) |
| 1193 | salt.enforceState(master, 'I@rundeck:server', 'rundeck.server') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | def installOss(master) { |
| 1198 | def common = new com.mirantis.mk.Common() |
| 1199 | def salt = new com.mirantis.mk.Salt() |
| 1200 | |
| 1201 | //Get oss VIP address |
| 1202 | def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address') |
| 1203 | common.prettyPrint(pillar) |
| 1204 | |
| 1205 | def oss_vip |
| 1206 | if(!pillar['return'].isEmpty()) { |
| 1207 | oss_vip = pillar['return'][0].values()[0] |
| 1208 | } else { |
| 1209 | common.errorMsg('[ERROR] Oss VIP address could not be retrieved') |
| 1210 | } |
| 1211 | |
| 1212 | // Postgres client - initialize OSS services databases |
| 1213 | timeout(120){ |
| 1214 | common.infoMsg("Waiting for postgresql database to come up..") |
Nikolas Britton | 4f62a09 | 2018-02-06 16:56:26 -0600 | [diff] [blame] | 1215 | salt.cmdRun(master, 'I@postgresql:client', 'while true; do if docker service logs postgresql_postgresql-db 2>&1 | grep "ready to accept"; then break; else sleep 5; fi; done') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1216 | } |
| 1217 | // XXX: first run usually fails on some inserts, but we need to create databases at first |
| 1218 | salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false) |
| 1219 | |
| 1220 | // Setup postgres database with integration between |
| 1221 | // Pushkin notification service and Security Monkey security audit service |
| 1222 | timeout(10) { |
| 1223 | common.infoMsg("Waiting for Pushkin to come up..") |
| 1224 | salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done") |
| 1225 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1226 | salt.enforceState(master, 'I@postgresql:client', 'postgresql.client') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1227 | |
| 1228 | // Rundeck |
| 1229 | timeout(10) { |
| 1230 | common.infoMsg("Waiting for Rundeck to come up..") |
| 1231 | salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done") |
| 1232 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1233 | salt.enforceState(master, 'I@rundeck:client', 'rundeck.client') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1234 | |
| 1235 | // Elasticsearch |
Mikhail Ivanov | fcd55d6 | 2017-12-19 16:51:35 +0400 | [diff] [blame] | 1236 | pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host') |
| 1237 | def elasticsearch_vip |
| 1238 | if(!pillar['return'].isEmpty()) { |
| 1239 | elasticsearch_vip = pillar['return'][0].values()[0] |
| 1240 | } else { |
| 1241 | common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| 1242 | } |
| 1243 | |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1244 | timeout(10) { |
| 1245 | common.infoMsg('Waiting for Elasticsearch to come up..') |
Mikhail Ivanov | fcd55d6 | 2017-12-19 16:51:35 +0400 | [diff] [blame] | 1246 | 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] | 1247 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 1248 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1249 | } |