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