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