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 | |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 22 | def installFoundationInfra(master, staticMgmtNet=false, extra_tgt = '', batch=20) { |
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. |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 29 | salt.enforceState([saltId: master, target: "I@salt:master ${extra_tgt}", state: ['reclass']]) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 30 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 31 | salt.enforceState([saltId: master, target: "I@salt:master ${extra_tgt}", state: ['linux.system']]) |
| 32 | salt.enforceState([saltId: master, target: "I@salt:master ${extra_tgt}", state: ['salt.master'], failOnError: false, read_timeout: 120, retries: 2]) |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 33 | salt.fullRefresh(master, "* ${extra_tgt}", batch) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 34 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 35 | salt.enforceState([saltId: master, target: "I@salt:master ${extra_tgt}", state: ['salt.minion'], failOnError: false, read_timeout: 60, retries: 2]) |
| 36 | salt.enforceState([saltId: master, target: "I@salt:master ${extra_tgt}", state: ['salt.minion']]) |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 37 | salt.fullRefresh(master, "* ${extra_tgt}", batch) |
| 38 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: ['linux.network.proxy'], batch: batch, failOnError: false, read_timeout: 180, retries: 2]) |
iberezovskiy | 6394a8a | 2018-10-12 13:16:47 +0400 | [diff] [blame] | 39 | // Make sure all repositories are in place before proceeding with package installation from other states |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 40 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: ['linux.system.repo'], batch: batch, failOnError: false, read_timeout: 180, retries: 2]) |
Jiri Broulik | 94fc259 | 2018-04-20 13:47:51 +0200 | [diff] [blame] | 41 | try { |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 42 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: ['salt.minion.base'], batch: batch, failOnError: false, read_timeout: 180, retries: 2]) |
Jiri Broulik | 94fc259 | 2018-04-20 13:47:51 +0200 | [diff] [blame] | 43 | sleep(5) |
| 44 | } catch (Throwable e) { |
| 45 | common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.') |
| 46 | } |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 47 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: ['linux.system'], batch: batch, retries: 2]) |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 48 | if (staticMgmtNet) { |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 49 | salt.runSaltProcessStep(master, "* ${extra_tgt}", 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], batch, true, 180) |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 50 | } |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 51 | salt.enforceState([saltId: master, target: "I@linux:network:interface ${extra_tgt}", state: ['linux.network.interface'], batch: batch, retries: 2]) |
Jiri Broulik | 9453846 | 2018-05-11 15:45:13 +0200 | [diff] [blame] | 52 | sleep(5) |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 53 | salt.enforceState([saltId: master, target: "I@linux:system ${extra_tgt}", state: ['linux', 'openssh', 'ntp', 'rsyslog'], batch: batch]) |
Ann Taraday | 4905976 | 2018-10-25 17:04:58 +0400 | [diff] [blame] | 54 | |
Ann Taraday | fb2d437 | 2018-10-30 17:17:09 +0400 | [diff] [blame] | 55 | |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 56 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: ['salt.minion'], failOnError: false, batch: batch, read_timeout: 180, retries: 2]) |
Ann Taraday | fb2d437 | 2018-10-30 17:17:09 +0400 | [diff] [blame] | 57 | |
Jakub Josef | 4f8f4df | 2017-09-01 14:32:42 +0200 | [diff] [blame] | 58 | sleep(5) |
Victor Ryzhenkin | f610c57 | 2018-05-15 15:22:52 +0400 | [diff] [blame] | 59 | |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 60 | salt.fullRefresh(master, "* ${extra_tgt}", batch) |
| 61 | salt.runSaltProcessStep(master, "* ${extra_tgt}", 'mine.update', [], batch, true) |
| 62 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: ['linux.network.host'], batch: batch]) |
Denis Egorenko | 2f9eec7 | 2019-11-01 18:04:02 +0400 | [diff] [blame] | 63 | // WA for PROD-33911 |
| 64 | salt.enforceState([saltId: master, target: "I@linux:system ${extra_tgt}", state: ['openssh'], batch: batch]) |
Ivan Suzdal | 9a6bc39 | 2018-04-26 18:29:56 +0400 | [diff] [blame] | 65 | |
| 66 | // Install and configure iptables |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 67 | salt.enforceStateWithTest([saltId: master, target: "I@iptables:service ${extra_tgt}", state: 'iptables', batch: batch]) |
sgarbuz | bb61e81 | 2018-05-03 16:58:40 +0300 | [diff] [blame] | 68 | |
| 69 | // Install and configure logrotate |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 70 | salt.enforceStateWithTest([saltId: master, target: "I@logrotate:server ${extra_tgt}", state: 'logrotate', batch: batch]) |
Ivan Suzdal | 9f8f0e1 | 2018-06-21 13:16:21 +0400 | [diff] [blame] | 71 | |
| 72 | // Install and configure auditd |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 73 | salt.enforceStateWithTest([saltId: master, target: "I@auditd:service ${extra_tgt}", state: 'auditd', batch: batch]) |
Ivan Suzdal | ca98091 | 2018-08-02 09:35:07 +0400 | [diff] [blame] | 74 | |
| 75 | // Install and configure openscap |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 76 | salt.enforceStateWithTest([saltId: master, target: "I@openscap:service ${extra_tgt}", state: 'openscap', batch: batch]) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 77 | } |
| 78 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 79 | def installFoundationInfraOnTarget(master, target, staticMgmtNet=false, extra_tgt = '') { |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 80 | def salt = new com.mirantis.mk.Salt() |
Jiri Broulik | 9fb138a | 2018-04-23 17:13:00 +0200 | [diff] [blame] | 81 | def common = new com.mirantis.mk.Common() |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 82 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 83 | salt.enforceState([saltId: master, target: "I@salt:master ${extra_tgt}", state: ['reclass'], failOnError: false, read_timeout: 120, retries: 2]) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 84 | salt.fullRefresh(master, target) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 85 | salt.enforceState([saltId: master, target: target, state: ['linux.network.proxy'], failOnError: false, read_timeout: 60, retries: 2]) |
Jiri Broulik | 94fc259 | 2018-04-20 13:47:51 +0200 | [diff] [blame] | 86 | try { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 87 | salt.enforceState([saltId: master, target: target, state: ['salt.minion.base'], failOnError: false, read_timeout: 60, retries: 2]) |
Jiri Broulik | 94fc259 | 2018-04-20 13:47:51 +0200 | [diff] [blame] | 88 | sleep(5) |
| 89 | } catch (Throwable e) { |
| 90 | common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.') |
| 91 | } |
Martin Polreich | 331f2b6 | 2019-02-08 10:16:52 +0100 | [diff] [blame] | 92 | salt.enforceState([saltId: master, target: target, state: ['linux.system'], retries: 2]) |
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 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 96 | salt.enforceState([saltId: master, target: target, state: ['salt.minion'], failOnError: false, read_timeout: 60, retries: 2]) |
| 97 | salt.enforceState([saltId: master, target: target, state: ['salt.minion']]) |
| 98 | salt.enforceState([saltId: master, target: target, state: ['linux.network.interface']]) |
Jiri Broulik | 9453846 | 2018-05-11 15:45:13 +0200 | [diff] [blame] | 99 | sleep(5) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 100 | salt.enforceState([saltId: master, target: target, state: ['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) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 105 | salt.enforceState([saltId: master, target: target, state: ['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}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 117 | salt.enforceState([saltId: master, target: "I@salt:control ${extra_tgt}", state: ['salt.minion'], failOnError: false, read_timeout: 60, retries: 2]) |
| 118 | salt.enforceState([saltId: master, target: "I@salt:control ${extra_tgt}", state: ['linux.system', 'linux.network', 'ntp', 'rsyslog']]) |
| 119 | salt.enforceState([saltId: master, target: "I@salt:control ${extra_tgt}", state: 'libvirt']) |
| 120 | salt.enforceState([saltId: master, target: "I@salt:control ${extra_tgt}", state: '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.") |
Denis Egorenko | 8006cce | 2019-08-26 13:16:23 +0400 | [diff] [blame] | 163 | salt.fullRefresh(master, "* and not I@salt:control ${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() |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 170 | def first_target |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 171 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 172 | // Install glusterfs |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 173 | if (salt.testTarget(master, "I@glusterfs:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 174 | salt.enforceState([saltId: master, target: "I@glusterfs:server ${extra_tgt}", state: 'glusterfs.server.service']) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 175 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 176 | salt.enforceState([saltId: master, target: "I@glusterfs:server:role:primary ${extra_tgt}", state: 'glusterfs.server.setup', retries: 5]) |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 177 | sleep(10) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 178 | 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] | 179 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 180 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 181 | // Ensure glusterfs clusters is ready |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 182 | salt.enforceStateWithTest([saltId: master, target: "I@glusterfs:client ${extra_tgt}", state: 'glusterfs.client', retries: 2]) |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 183 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 184 | // Install galera |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 185 | if (salt.testTarget(master, "I@galera:master ${extra_tgt}") || salt.testTarget(master, "I@galera:slave ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 186 | salt.enforceState([saltId: master, target: "I@galera:master ${extra_tgt}", state: 'galera', retries: 2]) |
| 187 | salt.enforceStateWithTest([saltId: master, target: "I@galera:slave ${extra_tgt}", state: 'galera', retries: 2]) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 188 | |
| 189 | // Check galera status |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 190 | salt.runSaltProcessStep(master, "I@galera:master ${extra_tgt}", 'mysql.status') |
Dzmitry Stremkouski | df727b2 | 2018-10-29 17:19:55 +0100 | [diff] [blame] | 191 | if (salt.testTarget(master, "I@galera:slave ${extra_tgt}")) { |
| 192 | salt.runSaltProcessStep(master, "I@galera:slave ${extra_tgt}", 'mysql.status') |
| 193 | } |
| 194 | |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 195 | // If galera is not enabled check if we need to install mysql:server |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 196 | } else { |
Dzmitry Stremkouski | df727b2 | 2018-10-29 17:19:55 +0100 | [diff] [blame] | 197 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 198 | salt.enforceStateWithTest([saltId: master, target: "I@mysql:server ${extra_tgt}", state: 'mysql.server']) |
| 199 | salt.enforceStateWithTest([saltId: master, target: "I@mysql:client ${extra_tgt}", state: 'mysql.client']) |
Dzmitry Stremkouski | df727b2 | 2018-10-29 17:19:55 +0100 | [diff] [blame] | 200 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 201 | } |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 202 | installBackup(master, 'mysql', extra_tgt) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 203 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 204 | // Install docker |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 205 | if (salt.testTarget(master, "I@docker:host ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 206 | salt.enforceState([saltId: master, target: "I@docker:host ${extra_tgt}", state: 'docker.host', retries: 3]) |
Pavel Cizinsky | ee34e31 | 2018-08-06 15:11:58 +0200 | [diff] [blame] | 207 | salt.cmdRun(master, "I@docker:host and I@docker:host:enabled:true ${extra_tgt}", 'docker ps') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 208 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 209 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 210 | // Install keepalived |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 211 | if (salt.testTarget(master, "I@keepalived:cluster ${extra_tgt}")) { |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 212 | first_target = salt.getFirstMinion(master, "I@keepalived:cluster ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 213 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'keepalived']) |
| 214 | salt.enforceState([saltId: master, target: "I@keepalived:cluster ${extra_tgt}", state: 'keepalived']) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | // Install rabbitmq |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 218 | if (salt.testTarget(master, "I@rabbitmq:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 219 | salt.enforceState([saltId: master, target: "I@rabbitmq:server ${extra_tgt}", state: 'rabbitmq', retries: 2]) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 220 | |
| 221 | // Check the rabbitmq status |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 222 | common.retry(3,5){ |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 223 | salt.cmdRun(master, "I@rabbitmq:server ${extra_tgt}", 'rabbitmqctl cluster_status') |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 224 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 225 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 226 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 227 | // Install haproxy |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 228 | if (salt.testTarget(master, "I@haproxy:proxy ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 229 | salt.enforceState([saltId: master, target: "I@haproxy:proxy ${extra_tgt}", state: 'haproxy']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 230 | salt.runSaltProcessStep(master, "I@haproxy:proxy ${extra_tgt}", 'service.status', ['haproxy']) |
| 231 | salt.runSaltProcessStep(master, "I@haproxy:proxy ${extra_tgt}", 'service.restart', ['rsyslog']) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 232 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 233 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 234 | // Install memcached |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 235 | salt.enforceStateWithTest([saltId: master, target: "I@memcached:server ${extra_tgt}", state: 'memcached']) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 236 | |
| 237 | // Install etcd |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 238 | if (salt.testTarget(master, "I@etcd:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 239 | salt.enforceState([saltId: master, target: "I@etcd:server ${extra_tgt}", state: 'etcd.server.service']) |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 240 | common.retry(3,5){ |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 241 | 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] | 242 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 243 | } |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 244 | |
| 245 | // Install redis |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 246 | if (salt.testTarget(master, "I@redis:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 247 | salt.enforceStateWithTest([saltId: master, target: "I@redis:cluster:role:master ${extra_tgt}", state: 'redis']) |
| 248 | salt.enforceState([saltId: master, target: "I@redis:server ${extra_tgt}", state: 'redis']) |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 249 | } |
Mykyta Karpin | 0a3dc8b | 2018-09-05 10:09:18 +0300 | [diff] [blame] | 250 | |
| 251 | // Install DNS services |
| 252 | if (salt.testTarget(master, "I@bind:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 253 | salt.enforceState([saltId: master, target: "I@bind:server ${extra_tgt}", state: 'bind.server']) |
Mykyta Karpin | 0a3dc8b | 2018-09-05 10:09:18 +0300 | [diff] [blame] | 254 | } |
| 255 | if (salt.testTarget(master, "I@powerdns:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 256 | salt.enforceState([saltId: master, target: "I@powerdns:server ${extra_tgt}", state: 'powerdns.server']) |
Mykyta Karpin | 0a3dc8b | 2018-09-05 10:09:18 +0300 | [diff] [blame] | 257 | } |
| 258 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 259 | installBackup(master, 'common', extra_tgt) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 260 | } |
| 261 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 262 | def installOpenstackInfra(master, extra_tgt = '') { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 263 | def common = new com.mirantis.mk.Common() |
| 264 | 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] | 265 | installInfra(master, extra_tgt) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 269 | def installOpenstackControl(master, extra_tgt = '') { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 270 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 271 | def common = new com.mirantis.mk.Common() |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 272 | def first_target |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 273 | |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 274 | // Install sphinx server |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 275 | salt.enforceStateWithTest([saltId: master, target: "I@sphinx:server ${extra_tgt}", state: 'sphinx']) |
Mykyta Karpin | 014131a | 2018-12-18 17:35:38 +0200 | [diff] [blame] | 276 | // Running minion states in a batch to avoid races related to certificates which are placed on glusterfs |
| 277 | // Details on races: https://mirantis.jira.com/browse/PROD-25796 |
| 278 | // TODO: Run in parallel when glusterfs for certificates is dropped in cookiecutter |
azvyagintsev | e9beda3 | 2019-06-07 15:20:52 +0300 | [diff] [blame] | 279 | salt.enforceStateWithTest([saltId: master, target: "I@nginx:server ${extra_tgt}", state: 'salt.minion', batch: 1, failOnError: false, retries: 2]) |
azvyagintsev | 4b8f402 | 2019-06-10 14:12:38 +0300 | [diff] [blame] | 280 | salt.enforceStateWithTest([saltId: master, target: "I@nginx:server ${extra_tgt}", state: 'salt.minion', batch: 1, failOnError: true, retries: 1]) |
azvyagintsev | e9beda3 | 2019-06-07 15:20:52 +0300 | [diff] [blame] | 281 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 282 | salt.enforceStateWithTest([saltId: master, target: "I@nginx:server ${extra_tgt}", state: 'nginx']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 283 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 284 | // setup keystone service |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 285 | if (salt.testTarget(master, "I@keystone:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 286 | salt.enforceState([saltId: master, target: "I@keystone:server:role:primary ${extra_tgt}", state: 'keystone.server']) |
| 287 | salt.enforceState([saltId: master, target: "I@keystone:server ${extra_tgt}", state: 'keystone.server']) |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 288 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 289 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 290 | // keystone:client must be called locally |
| 291 | //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] | 292 | salt.runSaltProcessStep(master, "I@keystone:server ${extra_tgt}", 'service.restart', ['apache2']) |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 293 | sleep(30) |
| 294 | } |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 295 | if (salt.testTarget(master, "I@keystone:client ${extra_tgt}")) { |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 296 | first_target = salt.getFirstMinion(master, "I@keystone:client ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 297 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'keystone.client']) |
| 298 | salt.enforceState([saltId: master, target: "I@keystone:client ${extra_tgt}", state: 'keystone.client']) |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 299 | } |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 300 | if (salt.testTarget(master, "I@keystone:server ${extra_tgt}")) { |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 301 | common.retry(3,5){ |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 302 | 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] | 303 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 304 | } |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 305 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 306 | // Install glance |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 307 | salt.enforceStateWithTest([saltId: master, target: "I@glance:server:role:primary ${extra_tgt}", state: 'glance.server', testTargetMatcher: "I@glance:server ${extra_tgt}"]) |
| 308 | salt.enforceStateWithTest([saltId: master, target: "I@glance:server ${extra_tgt}", state: 'glance.server']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 309 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 310 | // Check glance service |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 311 | if (salt.testTarget(master, "I@glance:server ${extra_tgt}")) { |
Mykyta Karpin | fc169b7 | 2018-11-19 09:57:07 +0200 | [diff] [blame] | 312 | common.retry(10,5){ |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 313 | 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] | 314 | } |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 315 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 316 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 317 | // Create glance resources |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 318 | salt.enforceStateWithTest([saltId: master, target: "I@glance:client ${extra_tgt}", state: 'glance.client']) |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 319 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 320 | // Install and check nova service |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 321 | // run on first node first |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 322 | salt.enforceStateWithTest([saltId: master, target: "I@nova:controller:role:primary ${extra_tgt}", state: 'nova.controller', testTargetMatcher: "I@nova:controller ${extra_tgt}"]) |
| 323 | salt.enforceStateWithTest([saltId: master, target: "I@nova:controller ${extra_tgt}", state: 'nova.controller']) |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 324 | if (salt.testTarget(master, "I@keystone:server and I@nova:controller ${extra_tgt}")) { |
| 325 | common.retry(3,5){ |
| 326 | salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; nova service-list') |
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 |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 331 | salt.enforceStateWithTest([saltId: master, target: "I@nova:client ${extra_tgt}", state: 'nova.client']) |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 332 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 333 | // Install and check cinder service |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 334 | // run on first node first |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 335 | salt.enforceStateWithTest([saltId: master, target: "I@cinder:controller:role:primary ${extra_tgt}", state: 'cinder', testTargetMatcher: "I@cinder:controller ${extra_tgt}"]) |
| 336 | salt.enforceStateWithTest([saltId: master, target: "I@cinder:controller ${extra_tgt}", state: 'cinder']) |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 337 | if (salt.testTarget(master, "I@keystone:server and I@cinder:controller ${extra_tgt}")) { |
| 338 | common.retry(3,5){ |
| 339 | salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; cinder list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 340 | } |
| 341 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 342 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 343 | // Install neutron service |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 344 | // run on first node first |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 345 | salt.enforceStateWithTest([saltId: master, target: "I@neutron:server:role:primary ${extra_tgt}", state: 'neutron.server', testTargetMatcher: "I@neutron:server ${extra_tgt}"]) |
| 346 | salt.enforceStateWithTest([saltId: master, target: "I@neutron:server ${extra_tgt}", state: 'neutron.server']) |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 347 | if (salt.testTarget(master, "I@keystone:server and I@neutron:server ${extra_tgt}")) { |
Vasyl Saienko | 0b86a4f | 2018-11-16 14:02:34 +0200 | [diff] [blame] | 348 | common.retry(10,5){ |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 349 | salt.cmdRun(master, "I@keystone:server ${extra_tgt}",'. /root/keystonercv3; neutron agent-list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 350 | } |
| 351 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 352 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 353 | // Install heat service |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 354 | salt.enforceStateWithTest([saltId: master, target: "I@heat:server:role:primary ${extra_tgt}", state: 'heat', testTargetMatcher: "I@heat:server ${extra_tgt}"]) |
| 355 | salt.enforceStateWithTest([saltId: master, target: "I@heat:server ${extra_tgt}", state: 'heat']) |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 356 | if (salt.testTarget(master, "I@keystone:server and I@heat:server ${extra_tgt}")) { |
Mykyta Karpin | a678da6 | 2018-12-20 17:26:51 +0200 | [diff] [blame] | 357 | common.retry(10,5){ |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 358 | salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; openstack orchestration resource type list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 359 | } |
| 360 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 361 | |
| 362 | // Restart nova api |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 363 | if (salt.testTarget(master, "I@nova:controller ${extra_tgt}")) { |
| 364 | salt.runSaltProcessStep(master, "I@nova:controller ${extra_tgt}", 'service.restart', ['nova-api']) |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 365 | } |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 366 | |
| 367 | // Install ironic service |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 368 | salt.enforceStateWithTest([saltId: master, target: "I@ironic:api:role:primary ${extra_tgt}", state: 'ironic.api', testTargetMatcher: "I@ironic:api ${extra_tgt}"]) |
| 369 | salt.enforceStateWithTest([saltId: master, target: "I@ironic:api ${extra_tgt}", state: 'ironic.api']) |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 370 | |
Vasyl Saienko | b7e4cdf | 2018-02-21 18:33:17 +0200 | [diff] [blame] | 371 | // Install manila service |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 372 | salt.enforceStateWithTest([saltId: master, target: "I@manila:api:role:primary ${extra_tgt}", state: 'manila.api', testTargetMatcher: "I@manila:api ${extra_tgt}"]) |
| 373 | salt.enforceStateWithTest([saltId: master, target: "I@manila:api ${extra_tgt}", state: 'manila.api']) |
| 374 | salt.enforceStateWithTest([saltId: master, target: "I@manila:scheduler ${extra_tgt}", state: 'manila.scheduler']) |
Vasyl Saienko | b7e4cdf | 2018-02-21 18:33:17 +0200 | [diff] [blame] | 375 | |
Oleh Hryhorov | a070fd0 | 2018-03-15 14:47:52 +0200 | [diff] [blame] | 376 | // Install designate services |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 377 | if (salt.testTarget(master, "I@designate:server:enabled ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 378 | salt.enforceState([saltId: master, target: "I@designate:server:role:primary ${extra_tgt}", state: 'designate.server']) |
| 379 | salt.enforceState([saltId: master, target: "I@designate:server ${extra_tgt}", state: 'designate']) |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 380 | } |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 381 | |
| 382 | // Install octavia api service |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 383 | salt.enforceStateWithTest([saltId: master, target: "I@octavia:api:role:primary ${extra_tgt}", state: 'octavia.api', testTargetMatcher: "I@octavia:api ${extra_tgt}"]) |
| 384 | salt.enforceStateWithTest([saltId: master, target: "I@octavia:api ${extra_tgt}", state: 'octavia.api']) |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 385 | |
Oleg Iurchenko | d0898c9 | 2017-12-14 14:28:44 +0200 | [diff] [blame] | 386 | // Install DogTag server service |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 387 | salt.enforceStateWithTest([saltId: master, target: "I@dogtag:server:role:master ${extra_tgt}", state: 'dogtag.server', testTargetMatcher: "I@dogtag:server ${extra_tgt}"]) |
Vasyl Saienko | 6f83b6b | 2019-02-01 11:55:52 +0200 | [diff] [blame] | 388 | // Run dogtag state on slaves in serial to avoid races during replications PROD-26810 |
| 389 | salt.enforceStateWithTest([saltId: master, target: "I@dogtag:server ${extra_tgt}", state: 'dogtag.server', batch: 1]) |
Oleg Iurchenko | d0898c9 | 2017-12-14 14:28:44 +0200 | [diff] [blame] | 390 | |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 391 | // Install barbican server service |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 392 | salt.enforceStateWithTest([saltId: master, target: "I@barbican:server:role:primary ${extra_tgt}", state: 'barbican.server', testTargetMatcher: "I@barbican:server ${extra_tgt}"]) |
| 393 | salt.enforceStateWithTest([saltId: master, target: "I@barbican:server ${extra_tgt}", state: 'barbican.server']) |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 394 | |
Vasyl Saienko | a96a766 | 2019-02-04 14:29:19 +0200 | [diff] [blame] | 395 | if (salt.testTarget(master, "I@barbican:server ${extra_tgt}")) { |
| 396 | // Restart apache to make sure we don't have races between barbican-api and barbican-worker on db init. |
| 397 | // For more info please see PROD-26988 |
| 398 | // The permanent fix is prepared to barbican formula https://gerrit.mcp.mirantis.com/#/c/35097/ but due to rush in release |
| 399 | // add this workaround here as well. |
| 400 | // TODO(vsaienko): cleanup once release passed in favor of permanent fix. |
| 401 | salt.runSaltProcessStep(master, "I@barbican:server ${extra_tgt}", 'service.restart', ['apache2']) |
| 402 | sleep(30) |
| 403 | } |
| 404 | |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 405 | // Install barbican client |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 406 | salt.enforceStateWithTest([saltId: master, target: "I@barbican:client ${extra_tgt}", state: 'barbican.client']) |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 407 | |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 408 | // Install gnocchi server |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 409 | salt.enforceStateWithTest([saltId: master, target: "I@gnocchi:server:role:primary ${extra_tgt}", state: 'gnocchi.server', testTargetMatcher: "I@gnocchi:server ${extra_tgt}"]) |
| 410 | salt.enforceStateWithTest([saltId: master, target: "I@gnocchi:server ${extra_tgt}", state: 'gnocchi.server']) |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 411 | |
Mykyta Karpin | 4816e52 | 2018-06-15 16:00:03 +0300 | [diff] [blame] | 412 | // Apply gnocchi client state to create gnocchi archive policies, due to possible |
| 413 | // races, apply on the first node initially |
| 414 | if (salt.testTarget(master, "I@gnocchi:client ${extra_tgt}")) { |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 415 | first_target = salt.getFirstMinion(master, "I@gnocchi:client ${extra_tgt}") |
Vasyl Saienko | a55e377 | 2019-07-24 15:31:00 +0300 | [diff] [blame] | 416 | // TODO(vsaienko) remove retries when they are moved to gnocchiv1 salt module. Related-Prod: PROD-32186 |
| 417 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'gnocchi.client', retries: 3]) |
| 418 | salt.enforceState([saltId: master, target: "I@gnocchi:client ${extra_tgt}", state: 'gnocchi.client', retries: 3]) |
Mykyta Karpin | 4816e52 | 2018-06-15 16:00:03 +0300 | [diff] [blame] | 419 | } |
| 420 | |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 421 | // Install gnocchi statsd |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 422 | if (salt.testTarget(master, "I@gnocchi:statsd ${extra_tgt}")) { |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 423 | first_target = salt.getFirstMinion(master, "I@gnocchi:statsd ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 424 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'gnocchi.statsd']) |
| 425 | salt.enforceState([saltId: master, target: "I@gnocchi:statsd ${extra_tgt}", state: 'gnocchi.statsd']) |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // Install panko server |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 429 | if (salt.testTarget(master, "I@panko:server ${extra_tgt}")) { |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 430 | first_target = salt.getFirstMinion(master, "I@panko:server ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 431 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'panko']) |
| 432 | salt.enforceState([saltId: master, target: "I@panko:server ${extra_tgt}", state: 'panko']) |
Mykyta Karpin | 8185e4a | 2018-02-23 19:15:48 +0200 | [diff] [blame] | 433 | } |
| 434 | |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 435 | // Install ceilometer server |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 436 | salt.enforceStateWithTest([saltId: master, target: "I@ceilometer:server:role:primary ${extra_tgt}", state: 'ceilometer', testTargetMatcher: "I@ceilometer:server ${extra_tgt}"]) |
| 437 | salt.enforceStateWithTest([saltId: master, target: "I@ceilometer:server ${extra_tgt}", state: 'ceilometer']) |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 438 | |
| 439 | // Install aodh server |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 440 | if (salt.testTarget(master, "I@aodh:server ${extra_tgt}")) { |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 441 | first_target = salt.getFirstMinion(master, "I@aodh:server ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 442 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'aodh']) |
| 443 | salt.enforceState([saltId: master, target: "I@aodh:server ${extra_tgt}", state: 'aodh']) |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 444 | } |
Oleksandr Bryndzii | 642cb25 | 2018-11-08 12:24:42 +0200 | [diff] [blame] | 445 | |
| 446 | // Install horizon dashboard |
Martin Polreich | c3e9d5d | 2019-11-27 16:24:04 +0100 | [diff] [blame] | 447 | salt.runSaltProcessStep(master, "* ${extra_tgt}", 'mine.update') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 448 | salt.enforceStateWithTest([saltId: master, target: "I@horizon:server ${extra_tgt}", state: 'horizon']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 452 | def installIronicConductor(master, extra_tgt = ''){ |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 453 | def salt = new com.mirantis.mk.Salt() |
| 454 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 455 | salt.enforceStateWithTest([saltId: master, target: "I@ironic:conductor ${extra_tgt}", state: 'ironic.conductor']) |
| 456 | salt.enforceStateWithTest([saltId: master, target: "I@ironic:conductor ${extra_tgt}", state: 'apache']) |
| 457 | salt.enforceStateWithTest([saltId: master, target: "I@tftpd_hpa:server ${extra_tgt}", state: 'tftpd_hpa']) |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 458 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 459 | if (salt.testTarget(master, "I@nova:compute ${extra_tgt}")) { |
| 460 | salt.runSaltProcessStep(master, "I@nova:compute ${extra_tgt}", 'service.restart', ['nova-compute']) |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 461 | } |
| 462 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 463 | salt.enforceStateWithTest([saltId: master, target: "I@baremetal_simulator:enabled ${extra_tgt}", state: 'baremetal_simulator']) |
| 464 | salt.enforceStateWithTest([saltId: master, target: "I@ironic:client ${extra_tgt}", state: 'ironic.client']) |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 465 | } |
| 466 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 467 | def installManilaShare(master, extra_tgt = ''){ |
Vasyl Saienko | b7e4cdf | 2018-02-21 18:33:17 +0200 | [diff] [blame] | 468 | def salt = new com.mirantis.mk.Salt() |
| 469 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 470 | salt.enforceStateWithTest([saltId: master, target: "I@manila:share ${extra_tgt}", state: 'manila.share']) |
| 471 | salt.enforceStateWithTest([saltId: master, target: "I@manila:data ${extra_tgt}", state: 'manila.data']) |
| 472 | salt.enforceStateWithTest([saltId: master, target: "I@manila:client ${extra_tgt}", state: 'manila.client']) |
Vasyl Saienko | b7e4cdf | 2018-02-21 18:33:17 +0200 | [diff] [blame] | 473 | } |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 474 | |
| 475 | |
Oleh Hryhorov | 37fbd0c | 2018-07-11 16:58:54 +0300 | [diff] [blame] | 476 | def installOpenstackNetwork(master, extra_tgt = '') { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 477 | def salt = new com.mirantis.mk.Salt() |
Ann Taraday | ea9848c | 2018-10-25 11:15:58 +0400 | [diff] [blame] | 478 | def common = new com.mirantis.mk.Common() |
Dzmitry Stremkouski | df727b2 | 2018-10-29 17:19:55 +0100 | [diff] [blame] | 479 | |
Oleksii Grudev | c4a485e | 2018-04-20 14:25:03 +0300 | [diff] [blame] | 480 | //run full neutron state on neutron.gateway - this will install |
| 481 | //neutron agents in addition to neutron server. Once neutron agents |
| 482 | //are up neutron resources can be created without hitting the situation when neutron resources are created |
| 483 | //prior to neutron agents which results in creating ports in non-usable state |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 484 | salt.enforceStateWithTest([saltId: master, target: "I@neutron:gateway ${extra_tgt}", state: 'neutron']) |
Oleksii Grudev | c4a485e | 2018-04-20 14:25:03 +0300 | [diff] [blame] | 485 | |
| 486 | // Create neutron resources - this step was moved here to ensure that |
| 487 | //neutron resources are created after neutron agens are up. In this case neutron ports will be in |
| 488 | //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249 |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 489 | salt.enforceStateWithTest([saltId: master, target: "I@neutron:client ${extra_tgt}", state: 'neutron.client']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 490 | |
Dzmitry Stremkouski | df727b2 | 2018-10-29 17:19:55 +0100 | [diff] [blame] | 491 | if (salt.testTarget(master, "I@neutron:gateway ${extra_tgt}")) { |
| 492 | salt.enforceHighstate(master, "I@neutron:gateway ${extra_tgt}") |
| 493 | } |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 494 | |
| 495 | // install octavia manager services |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 496 | if (salt.testTarget(master, "I@octavia:manager ${extra_tgt}")) { |
Anna Taraday | 8222410 | 2018-10-09 07:44:24 +0000 | [diff] [blame] | 497 | salt.runSaltProcessStep(master, "I@neutron:client ${extra_tgt}", 'mine.update') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 498 | salt.enforceState([saltId: master, target: "I@octavia:manager ${extra_tgt}", state: 'octavia.manager']) |
| 499 | salt.enforceState([saltId: master, target: "I@octavia:client ${extra_tgt}", state: 'octavia.client']) |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 500 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 504 | def installOpenstackCompute(master, extra_tgt = '', batch=20) { |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 505 | def salt = new com.mirantis.mk.Salt() |
Mykyta Karpin | 3ec78a2 | 2018-07-10 12:27:09 +0300 | [diff] [blame] | 506 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 507 | // Configure compute nodes |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 508 | def compute_compound = "I@nova:compute ${extra_tgt}" |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 509 | if (salt.testTarget(master, compute_compound, batch)) { |
Dzmitry Stremkouski | feb8ce9 | 2018-03-21 18:03:28 +0100 | [diff] [blame] | 510 | // In case if infrastructure nodes are used as nova computes too |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 511 | def gluster_compound = "I@glusterfs:server ${extra_tgt}" |
| 512 | 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] | 513 | // 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] | 514 | def hightstateTarget = "${compute_compound} and not ${gluster_compound} and not ${salt_ca_compound}" |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 515 | if (salt.testTarget(master, hightstateTarget, batch)) { |
Oleh Hryhorov | 73f9fa2 | 2018-05-02 17:36:58 +0300 | [diff] [blame] | 516 | retry(2) { |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 517 | salt.enforceHighstate(master, hightstateTarget, false, true, batch) |
Oleh Hryhorov | 73f9fa2 | 2018-05-02 17:36:58 +0300 | [diff] [blame] | 518 | } |
Mykyta Karpin | b1eaba9 | 2018-07-10 10:09:37 +0300 | [diff] [blame] | 519 | } else { |
| 520 | common.infoMsg("No minions matching highstate target found for target ${hightstateTarget}") |
Dzmitry Stremkouski | 7eca99d | 2018-04-25 18:44:26 +0200 | [diff] [blame] | 521 | } |
| 522 | // Iterate through salt ca servers and check if they have compute role |
| 523 | // TODO: switch to batch once salt 2017.7+ would be used |
Mykyta Karpin | b1eaba9 | 2018-07-10 10:09:37 +0300 | [diff] [blame] | 524 | common.infoMsg("Checking whether ${salt_ca_compound} minions have ${compute_compound} compound") |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 525 | for ( target in salt.getMinionsSorted(master, salt_ca_compound, batch) ) { |
| 526 | for ( cmp_target in salt.getMinionsSorted(master, compute_compound, batch) ) { |
Dzmitry Stremkouski | 7eca99d | 2018-04-25 18:44:26 +0200 | [diff] [blame] | 527 | if ( target == cmp_target ) { |
| 528 | // Enforce highstate one by one on salt ca servers which are compute nodes |
| 529 | retry(2) { |
Vasyl Saienko | be599d1 | 2018-11-10 06:42:50 +0000 | [diff] [blame] | 530 | salt.enforceHighstate(master, target) |
Dzmitry Stremkouski | 7eca99d | 2018-04-25 18:44:26 +0200 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | } |
Dzmitry Stremkouski | feb8ce9 | 2018-03-21 18:03:28 +0100 | [diff] [blame] | 534 | } |
| 535 | // Iterate through glusterfs servers and check if they have compute role |
| 536 | // TODO: switch to batch once salt 2017.7+ would be used |
Mykyta Karpin | b1eaba9 | 2018-07-10 10:09:37 +0300 | [diff] [blame] | 537 | common.infoMsg("Checking whether ${gluster_compound} minions have ${compute_compound} compound") |
Martin Polreich | f797695 | 2019-03-04 10:06:11 +0100 | [diff] [blame] | 538 | for ( target in salt.getMinionsSorted(master, gluster_compound, batch) ) { |
| 539 | for ( cmp_target in salt.getMinionsSorted(master, compute_compound, batch) ) { |
Dzmitry Stremkouski | feb8ce9 | 2018-03-21 18:03:28 +0100 | [diff] [blame] | 540 | if ( target == cmp_target ) { |
| 541 | // Enforce highstate one by one on glusterfs servers which are compute nodes |
| 542 | retry(2) { |
Vasyl Saienko | be599d1 | 2018-11-10 06:42:50 +0000 | [diff] [blame] | 543 | salt.enforceHighstate(master, target) |
Dzmitry Stremkouski | feb8ce9 | 2018-03-21 18:03:28 +0100 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | } |
Sergio Lystopad | cd5b277 | 2018-02-09 14:37:10 +0200 | [diff] [blame] | 547 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 548 | } |
Vasyl Saienko | 51144e4 | 2018-06-19 09:30:30 +0300 | [diff] [blame] | 549 | |
| 550 | // Run nova:controller to map cmp with cells |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 551 | salt.enforceStateWithTest([saltId: master, target: "I@nova:controller:role:primary ${extra_tgt}", state: 'nova.controller', testTargetMatcher: "I@nova:controller ${extra_tgt}"]) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 555 | def installContrailNetwork(master, extra_tgt = '') { |
Martin Polreich | fc9854c | 2017-06-30 11:17:36 +0200 | [diff] [blame] | 556 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 557 | def salt = new com.mirantis.mk.Salt() |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 558 | def first_target |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 559 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 560 | // Install opencontrail database services |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 561 | first_target = salt.getFirstMinion(master, "I@opencontrail:database ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 562 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'opencontrail.database']) |
| 563 | salt.enforceState([saltId: master, target: "I@opencontrail:database ${extra_tgt}", state: 'opencontrail.database']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 564 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 565 | // Install opencontrail control services |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 566 | first_target = salt.getFirstMinion(master, "I@opencontrail:control ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 567 | salt.enforceStateWithExclude([saltId: master, target: "${first_target} ${extra_tgt}", state: "opencontrail", excludedStates: "opencontrail.client"]) |
| 568 | salt.enforceStateWithExclude([saltId: master, target: "I@opencontrail:control ${extra_tgt}", state: "opencontrail", excludedStates: "opencontrail.client"]) |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 569 | first_target = salt.getFirstMinion(master, "I@opencontrail:collector ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 570 | salt.enforceStateWithExclude([saltId: master, target: "${first_target} ${extra_tgt}", state: "opencontrail", excludedStates: "opencontrail.client"]) |
| 571 | salt.enforceStateWithExclude([saltId: master, target: "I@opencontrail:collector ${extra_tgt}", state: "opencontrail", excludedStates: "opencontrail.client"]) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 572 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 573 | salt.enforceStateWithTest([saltId: master, target: "( I@opencontrail:control or I@opencontrail:collector ) ${extra_tgt}", state: 'docker.client', testTargetMatcher: "I@docker:client and I@opencontrail:control ${extra_tgt}"]) |
Anton Samoylov | 328a572 | 2019-01-23 17:37:33 +0400 | [diff] [blame] | 574 | } |
Svimba | fb242db | 2019-01-09 17:27:20 +0100 | [diff] [blame] | 575 | |
Anton Samoylov | 328a572 | 2019-01-23 17:37:33 +0400 | [diff] [blame] | 576 | |
| 577 | def checkContrailApiReadiness(master, extra_tgt = '') { |
| 578 | def common = new com.mirantis.mk.Common() |
| 579 | def salt = new com.mirantis.mk.Salt() |
| 580 | |
Anton Samoylov | af569b5 | 2019-01-25 14:49:52 +0400 | [diff] [blame] | 581 | def apiCheckResult = salt.getReturnValues(salt.runSaltProcessStep(master, "I@opencontrail:control:role:primary ${extra_tgt}", 'contrail_health.get_api_status', ['wait_for=900', 'tries=50'])) |
Anton Samoylov | 37b5829 | 2019-01-22 15:28:31 +0400 | [diff] [blame] | 582 | if (!apiCheckResult){ |
| 583 | throw new Exception("Contrail is not working after deployment: contrail-api service is not in healthy state") |
Anton Samoylov | 328a572 | 2019-01-23 17:37:33 +0400 | [diff] [blame] | 584 | } else { |
| 585 | common.infoMsg('Contrail API is ready to service requests') |
Anton Samoylov | 37b5829 | 2019-01-22 15:28:31 +0400 | [diff] [blame] | 586 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 590 | def installContrailCompute(master, extra_tgt = '') { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 591 | def salt = new com.mirantis.mk.Salt() |
vrovachev | 32f7f54 | 2017-08-25 16:17:25 +0400 | [diff] [blame] | 592 | def common = new com.mirantis.mk.Common() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 593 | // Configure compute nodes |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 594 | // Provision opencontrail control services |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 595 | salt.enforceState([saltId: master, target: "I@opencontrail:database:id:1 ${extra_tgt}", state: 'opencontrail.client']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 596 | // Provision opencontrail virtual routers |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 597 | |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 598 | // Generate script /usr/lib/contrail/if-vhost0 for up vhost0 |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 599 | if (salt.testTarget(master, "I@opencontrail:compute ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 600 | salt.enforceStateWithExclude([saltId: master, target: "I@opencontrail:compute ${extra_tgt}", state: "opencontrail", excludedStates: "opencontrail.client"]) |
Sergio Lystopad | cd5b277 | 2018-02-09 14:37:10 +0200 | [diff] [blame] | 601 | } |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 602 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 603 | if (salt.testTarget(master, "I@nova:compute ${extra_tgt}")) { |
Anton Samoylov | 817b0df | 2018-12-11 19:00:28 +0400 | [diff] [blame] | 604 | salt.cmdRun(master, "I@nova:compute ${extra_tgt}", 'exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || reboot & "', false) |
Sergio Lystopad | cd5b277 | 2018-02-09 14:37:10 +0200 | [diff] [blame] | 605 | } |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 606 | |
Jakub Josef | 61463c7 | 2018-02-13 16:10:56 +0100 | [diff] [blame] | 607 | sleep(300) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 608 | salt.enforceStateWithTest([saltId: master, target: "I@opencontrail:compute ${extra_tgt}", state: 'opencontrail.client']) |
| 609 | salt.enforceStateWithTest([saltId: master, target: "I@opencontrail:compute ${extra_tgt}", state: 'opencontrail']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 613 | def installKubernetesInfra(master, extra_tgt = '') { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 614 | def common = new com.mirantis.mk.Common() |
| 615 | 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] | 616 | installInfra(master, extra_tgt) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 620 | def installKubernetesControl(master, extra_tgt = '') { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 621 | def salt = new com.mirantis.mk.Salt() |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 622 | def first_target |
Victor Ryzhenkin | eb61741 | 2018-08-20 18:54:23 +0400 | [diff] [blame] | 623 | salt.fullRefresh(master, "* ${extra_tgt}") |
| 624 | |
| 625 | // Bootstrap all nodes |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 626 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: 'linux']) |
| 627 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: 'salt.minion']) |
| 628 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: ['openssh', 'ntp']]) |
Victor Ryzhenkin | eb61741 | 2018-08-20 18:54:23 +0400 | [diff] [blame] | 629 | |
| 630 | // Create and distribute SSL certificates for services using salt state |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 631 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: 'salt.minion.cert']) |
Victor Ryzhenkin | eb61741 | 2018-08-20 18:54:23 +0400 | [diff] [blame] | 632 | |
| 633 | // Install docker |
Victor Ryzhenkin | dbb3986 | 2019-01-09 18:24:16 +0400 | [diff] [blame] | 634 | salt.enforceStateWithTest([saltId: master, target: "I@docker:host ${extra_tgt}", state: 'docker.host']) |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 635 | |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 636 | // If network engine is not opencontrail, run addons state for kubernetes |
Stanislav Riazanov | bae038c | 2019-04-16 17:18:12 +0400 | [diff] [blame] | 637 | if (!salt.getReturnValues(salt.getPillar(master, "I@kubernetes:master ${extra_tgt}", 'kubernetes:master:network:opencontrail:enabled'))) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 638 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: 'kubernetes.master.kube-addons']) |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 639 | } |
| 640 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 641 | // Install Kubernetes pool and Calico |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 642 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: 'kubernetes.pool']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 643 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 644 | if (salt.testTarget(master, "I@etcd:server:setup ${extra_tgt}")) { |
Marek Celoud | 029391c | 2017-11-14 10:06:18 +0100 | [diff] [blame] | 645 | // Setup etcd server |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 646 | first_target = salt.getFirstMinion(master, "I@kubernetes:master ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 647 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'etcd.server.setup']) |
Marek Celoud | 029391c | 2017-11-14 10:06:18 +0100 | [diff] [blame] | 648 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 649 | |
Victor Ryzhenkin | fb5d1b5 | 2018-05-22 18:49:26 +0400 | [diff] [blame] | 650 | // Run k8s master at *01* to simplify namespaces creation |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 651 | first_target = salt.getFirstMinion(master, "I@kubernetes:master ${extra_tgt}") |
Victor Ryzhenkin | fb5d1b5 | 2018-05-22 18:49:26 +0400 | [diff] [blame] | 652 | |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 653 | // If network engine is opencontrail, run master state for kubernetes without kube-addons |
| 654 | // The kube-addons state will be called later only in case of opencontrail |
Stanislav Riazanov | bae038c | 2019-04-16 17:18:12 +0400 | [diff] [blame] | 655 | if (salt.getReturnValues(salt.getPillar(master, "I@kubernetes:master ${extra_tgt}", 'kubernetes:master:network:opencontrail:enabled'))) { |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 656 | // Run k8s on first node without master.setup and master.kube-addons |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 657 | salt.enforceStateWithExclude([saltId: master, target: "${first_target} ${extra_tgt}", state: "kubernetes.master", excludedStates: "kubernetes.master.setup,kubernetes.master.kube-addons"]) |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 658 | // Run k8s without master.setup and master.kube-addons |
Vasyl Saienko | d96805b | 2019-03-05 10:48:34 +0200 | [diff] [blame] | 659 | salt.enforceStateWithExclude([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: "kubernetes", excludedStates: "kubernetes.master.setup,kubernetes.master.kube-addons,kubernetes.client"]) |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 660 | } else { |
| 661 | // Run k8s on first node without master.setup and master.kube-addons |
Stanislav Riazanov | bae038c | 2019-04-16 17:18:12 +0400 | [diff] [blame] | 662 | salt.enforceStateWithExclude([saltId: master, target: "${first_target} ${extra_tgt}", state: "kubernetes.master", excludedStates: "kubernetes.master.setup,kubernetes.master.kube-addons"]) |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 663 | // Run k8s without master.setup |
Stanislav Riazanov | bae038c | 2019-04-16 17:18:12 +0400 | [diff] [blame] | 664 | salt.enforceStateWithExclude([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: "kubernetes", excludedStates: "kubernetes.master.setup,kubernetes.client,kubernetes.control*"]) |
| 665 | // Run k8s control on first node only |
| 666 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'kubernetes.control']) |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 667 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 668 | |
| 669 | // Run k8s master setup |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 670 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: 'kubernetes.master.setup']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 671 | |
| 672 | // Restart kubelet |
Victor Ryzhenkin | c8d5f8f | 2018-09-10 16:55:13 +0400 | [diff] [blame] | 673 | salt.runSaltProcessStep(master, "I@kubernetes:master ${extra_tgt}", 'service.restart', ['kubelet']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 677 | def installKubernetesCompute(master, extra_tgt = '') { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 678 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame] | 679 | salt.fullRefresh(master, "*") |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 680 | |
| 681 | // Bootstrap all nodes |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 682 | salt.enforceState([saltId: master, target: "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", state: 'linux']) |
| 683 | salt.enforceState([saltId: master, target: "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", state: 'salt.minion']) |
| 684 | salt.enforceState([saltId: master, target: "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", state: ['openssh', 'ntp']]) |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 685 | |
| 686 | // Create and distribute SSL certificates for services using salt state |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 687 | salt.enforceState([saltId: master, target: "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", state: 'salt.minion.cert']) |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 688 | |
| 689 | // Install docker |
Victor Ryzhenkin | dbb3986 | 2019-01-09 18:24:16 +0400 | [diff] [blame] | 690 | salt.enforceStateWithTest([saltId: master, target: "I@docker:host ${extra_tgt}", state: 'docker.host']) |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 691 | |
| 692 | // Install Kubernetes and Calico |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 693 | salt.enforceState([saltId: master, target: "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", state: 'kubernetes.pool']) |
Victor Ryzhenkin | c8d5f8f | 2018-09-10 16:55:13 +0400 | [diff] [blame] | 694 | salt.runSaltProcessStep(master, "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", 'service.restart', ['kubelet']) |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 695 | } |
| 696 | |
Vasyl Saienko | 0cf55df | 2019-03-05 10:51:22 +0200 | [diff] [blame] | 697 | def installKubernetesClient(master, extra_tgt = '') { |
| 698 | def salt = new com.mirantis.mk.Salt() |
| 699 | |
| 700 | // Install kubernetes client |
| 701 | salt.enforceStateWithTest([saltId: master, target: "I@kubernetes:client ${extra_tgt}", state: 'kubernetes.client']) |
| 702 | } |
| 703 | |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 704 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 705 | def installDockerSwarm(master, extra_tgt = '') { |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 706 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 707 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 708 | //Install and Configure Docker |
Martin Polreich | c0bb4fd | 2018-08-06 11:34:43 +0200 | [diff] [blame] | 709 | if (salt.testTarget(master, "I@docker:swarm ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 710 | salt.enforceState([saltId: master, target: "I@docker:swarm ${extra_tgt}", state: 'docker.host']) |
| 711 | salt.enforceState([saltId: master, target: "I@docker:swarm:role:master ${extra_tgt}", state: 'docker.swarm']) |
| 712 | salt.enforceState([saltId: master, target: "I@docker:swarm ${extra_tgt}", state: 'salt.minion.grains']) |
Martin Polreich | c0bb4fd | 2018-08-06 11:34:43 +0200 | [diff] [blame] | 713 | salt.runSaltProcessStep(master, "I@docker:swarm ${extra_tgt}", 'mine.update') |
| 714 | salt.runSaltProcessStep(master, "I@docker:swarm ${extra_tgt}", 'saltutil.refresh_modules') |
| 715 | sleep(5) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 716 | salt.enforceState([saltId: master, target: "I@docker:swarm:role:master ${extra_tgt}", state: 'docker.swarm']) |
| 717 | salt.enforceStateWithTest([saltId: master, target: "I@docker:swarm:role:manager ${extra_tgt}", state: 'docker.swarm']) |
Martin Polreich | c0bb4fd | 2018-08-06 11:34:43 +0200 | [diff] [blame] | 718 | sleep(10) |
| 719 | salt.cmdRun(master, "I@docker:swarm:role:master ${extra_tgt}", 'docker node ls') |
Machi Hoshino | 87aa39d | 2018-07-26 20:41:53 +0900 | [diff] [blame] | 720 | } |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 721 | } |
| 722 | |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 723 | // Setup addons for kubernetes - For OpenContrail network engine |
| 724 | // Use after compute nodes are ready, because K8s addons like DNS should be placed on cmp nodes |
| 725 | def setupKubeAddonForContrail(master, extra_tgt = '') { |
| 726 | def salt = new com.mirantis.mk.Salt() |
| 727 | |
| 728 | if (salt.getPillar(master, "I@kubernetes:master ${extra_tgt}", 'kubernetes:master:network:opencontrail:enabled')){ |
| 729 | // Setup Addons for Kubernetes only in case of OpenContrail is used as neteork engine |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 730 | salt.enforceState([saltId: master, target: "I@kubernetes:master ${extra_tgt}", state: 'kubernetes.master.kube-addons']) |
Svimba | 470b331 | 2018-09-26 11:27:20 +0200 | [diff] [blame] | 731 | } |
| 732 | } |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 733 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 734 | def installCicd(master, extra_tgt = '') { |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 735 | def salt = new com.mirantis.mk.Salt() |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 736 | def common = new com.mirantis.mk.Common() |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 737 | def gerrit_compound = "I@gerrit:client ${extra_tgt}" |
| 738 | def jenkins_compound = "I@jenkins:client ${extra_tgt}" |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 739 | |
| 740 | salt.fullRefresh(master, gerrit_compound) |
| 741 | salt.fullRefresh(master, jenkins_compound) |
Richard Felkl | 9d2cd92 | 2017-11-03 11:49:32 +0100 | [diff] [blame] | 742 | |
Ivan Berezovskiy | 3aa91f5 | 2018-11-28 18:47:34 +0400 | [diff] [blame] | 743 | // Temporary exclude cfg node from docker.client state (PROD-24934) |
| 744 | def dockerClientExclude = !salt.getPillar(master, 'I@salt:master', 'docker:client:stack:jenkins').isEmpty() ? 'and not I@salt:master' : '' |
Ivan Berezovskiy | 2d6b3d5 | 2018-12-24 18:31:39 +0400 | [diff] [blame] | 745 | // Pull images first if any |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 746 | def listCIMinions = salt.getMinions(master, "* ${dockerClientExclude} ${extra_tgt}") |
Ivan Berezovskiy | 2d6b3d5 | 2018-12-24 18:31:39 +0400 | [diff] [blame] | 747 | for (int i = 0; i < listCIMinions.size(); i++) { |
| 748 | if (!salt.getReturnValues(salt.getPillar(master, listCIMinions[i], 'docker:client:images')).isEmpty()) { |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 749 | salt.enforceStateWithTest([saltId: master, target: listCIMinions[i], state: 'docker.client.images', retries: 2]) |
Ivan Berezovskiy | 2d6b3d5 | 2018-12-24 18:31:39 +0400 | [diff] [blame] | 750 | } |
| 751 | } |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 752 | salt.enforceStateWithTest([saltId: master, target: "I@docker:swarm:role:master and I@jenkins:client ${dockerClientExclude} ${extra_tgt}", state: 'docker.client', retries: 2]) |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 753 | |
| 754 | // API timeout in minutes |
| 755 | def wait_timeout = 10 |
| 756 | |
| 757 | // Gerrit |
| 758 | def gerrit_master_url = salt.getPillar(master, gerrit_compound, '_param:gerrit_master_url') |
| 759 | |
| 760 | if(!gerrit_master_url['return'].isEmpty()) { |
| 761 | gerrit_master_url = gerrit_master_url['return'][0].values()[0] |
| 762 | } else { |
| 763 | gerrit_master_url = '' |
| 764 | } |
| 765 | |
| 766 | if (gerrit_master_url != '') { |
| 767 | common.infoMsg('Gerrit master url "' + gerrit_master_url + '" retrieved at _param:gerrit_master_url') |
| 768 | } else { |
| 769 | |
| 770 | common.infoMsg('Gerrit master url could not be retrieved at _param:gerrit_master_url. Falling back to gerrit pillar') |
| 771 | |
| 772 | def gerrit_host |
| 773 | def gerrit_http_port |
| 774 | def gerrit_http_scheme |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 775 | def gerrit_http_prefix |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 776 | |
| 777 | def host_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:host') |
| 778 | gerrit_host = salt.getReturnValues(host_pillar) |
| 779 | |
| 780 | def port_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:http_port') |
| 781 | gerrit_http_port = salt.getReturnValues(port_pillar) |
| 782 | |
| 783 | def scheme_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:protocol') |
| 784 | gerrit_http_scheme = salt.getReturnValues(scheme_pillar) |
| 785 | |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 786 | def prefix_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:url_prefix') |
| 787 | gerrit_http_prefix = salt.getReturnValues(prefix_pillar) |
| 788 | |
| 789 | gerrit_master_url = gerrit_http_scheme + '://' + gerrit_host + ':' + gerrit_http_port + gerrit_http_prefix |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 790 | |
| 791 | } |
| 792 | |
| 793 | timeout(wait_timeout) { |
| 794 | common.infoMsg('Waiting for Gerrit to come up..') |
Dzmitry Stremkouski | 5440ffa | 2018-05-31 12:00:02 +0200 | [diff] [blame] | 795 | 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' |
| 796 | 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] | 797 | } |
| 798 | |
| 799 | // Jenkins |
Ivan Berezovskiy | 5f8e64c | 2019-05-21 16:18:51 +0400 | [diff] [blame] | 800 | def jenkins_master_host = salt.getReturnValues(salt.getPillar(master, jenkins_compound, '_param:jenkins_master_host')) |
| 801 | def jenkins_master_port = salt.getReturnValues(salt.getPillar(master, jenkins_compound, '_param:jenkins_master_port')) |
| 802 | def jenkins_master_protocol = salt.getReturnValues(salt.getPillar(master, jenkins_compound, '_param:jenkins_master_protocol')) |
| 803 | def jenkins_master_url_prefix = salt.getReturnValues(salt.getPillar(master, jenkins_compound, '_param:jenkins_master_url_prefix')) |
| 804 | jenkins_master_url = "${jenkins_master_protocol}://${jenkins_master_host}:${jenkins_master_port}${jenkins_master_url_prefix}" |
Dzmitry Stremkouski | f8a873e | 2018-05-05 22:15:27 +0200 | [diff] [blame] | 805 | |
| 806 | timeout(wait_timeout) { |
| 807 | common.infoMsg('Waiting for Jenkins to come up..') |
Dzmitry Stremkouski | 5440ffa | 2018-05-31 12:00:02 +0200 | [diff] [blame] | 808 | 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' |
| 809 | 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] | 810 | } |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 811 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 812 | salt.enforceStateWithTest([saltId: master, target: "I@openldap:client ${extra_tgt}", state: 'openldap', retries: 2]) |
Richard Felkl | b6fdec9 | 2017-09-26 10:52:36 +0200 | [diff] [blame] | 813 | |
Denis Egorenko | c6df9fc | 2020-01-15 17:59:34 +0400 | [diff] [blame] | 814 | salt.enforceStateWithTest([saltId: master, target: "( I@keycloak:server or I@keycloak:proxy ) ${extra_tgt}", state: 'keycloak', retries: 2]) |
| 815 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 816 | salt.enforceStateWithTest([saltId: master, target: "I@python:environment ${extra_tgt}", state: 'python']) |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 817 | |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 818 | withEnv(['ASK_ON_ERROR=false']){ |
| 819 | retry(2){ |
| 820 | try{ |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 821 | salt.enforceStateWithTest([saltId: master, target: "I@gerrit:client ${extra_tgt}", state: 'gerrit']) |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 822 | }catch(e){ |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 823 | salt.fullRefresh(master, "I@gerrit:client ${extra_tgt}") |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 824 | throw e //rethrow for retry handler |
| 825 | } |
| 826 | } |
| 827 | retry(2){ |
| 828 | try{ |
Stanislav Riazanov | cfc4ac5 | 2019-03-04 17:44:06 +0400 | [diff] [blame] | 829 | salt.enforceStateWithTest([saltId: master, target: "I@jenkins:client ${extra_tgt}", state: 'jenkins']) |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 830 | }catch(e){ |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 831 | salt.fullRefresh(master, "I@jenkins:client ${extra_tgt}") |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 832 | throw e //rethrow for retry handler |
| 833 | } |
| 834 | } |
| 835 | } |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 839 | def installStacklight(master, extra_tgt = '') { |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 840 | def common = new com.mirantis.mk.Common() |
| 841 | def salt = new com.mirantis.mk.Salt() |
Martin Polreich | 331f2b6 | 2019-02-08 10:16:52 +0100 | [diff] [blame] | 842 | def step_retries_wait = 20 |
| 843 | def step_retries = 15 |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 844 | def first_target |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 845 | |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 846 | // Install core services for K8S environments: |
azvyagintsev | 833b477 | 2018-11-21 22:30:59 +0200 | [diff] [blame] | 847 | // HAProxy, Nginx and glusterFS clients. |
| 848 | // glusterFS clients must be first one, since nginx should store certs on it. |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 849 | // In case of OpenStack, those are already installed |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 850 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 851 | salt.enforceStateWithTest([saltId: master, target: "I@glusterfs:client ${extra_tgt}", state: 'glusterfs.client', retries: 2]) |
Martin Polreich | 331f2b6 | 2019-02-08 10:16:52 +0100 | [diff] [blame] | 852 | salt.enforceState([saltId: master, target: "I@nginx:server ${extra_tgt}", state: 'salt.minion.cert', retries: 3]) |
azvyagintsev | 833b477 | 2018-11-21 22:30:59 +0200 | [diff] [blame] | 853 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 854 | salt.enforceState([saltId: master, target: "I@haproxy:proxy ${extra_tgt}", state: 'haproxy']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 855 | salt.runSaltProcessStep(master, "I@haproxy:proxy ${extra_tgt}", 'service.status', ['haproxy']) |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 856 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 857 | salt.enforceStateWithTest([saltId: master, target: "I@nginx:server ${extra_tgt}", state: 'nginx']) |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 858 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 859 | |
Dmitry Kalashnik | 69ecb78 | 2018-05-21 17:36:50 +0400 | [diff] [blame] | 860 | // Install MongoDB for Alerta |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 861 | if (salt.testTarget(master, "I@mongodb:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 862 | salt.enforceState([saltId: master, target: "I@mongodb:server ${extra_tgt}", state: 'mongodb.server']) |
Ildar Svetlov | 829f94a | 2018-06-05 17:57:08 +0400 | [diff] [blame] | 863 | |
| 864 | // Initialize mongodb replica set |
Martin Polreich | 331f2b6 | 2019-02-08 10:16:52 +0100 | [diff] [blame] | 865 | salt.enforceState([saltId: master, target: "I@mongodb:server ${extra_tgt}", state: 'mongodb.cluster', retries: 5, retries_wait: 20]) |
Dmitry Kalashnik | 69ecb78 | 2018-05-21 17:36:50 +0400 | [diff] [blame] | 866 | } |
| 867 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 868 | //Install Telegraf |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 869 | salt.enforceState([saltId: master, target: "( I@telegraf:agent or I@telegraf:remote_agent ) ${extra_tgt}", state: 'telegraf']) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 870 | |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 871 | // Install Prometheus exporters |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 872 | salt.enforceStateWithTest([saltId: master, target: "I@prometheus:exporters ${extra_tgt}", state: 'prometheus']) |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 873 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 874 | //Install Elasticsearch and Kibana |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 875 | if (salt.testTarget(master, "I@elasticsearch:server:enabled:true ${extra_tgt}")) { |
| 876 | first_target = salt.getFirstMinion(master, "I@elasticsearch:server:enabled:true ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 877 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'elasticsearch.server']) |
Ramon Melero | ae6e16a | 2018-08-07 13:42:16 -0500 | [diff] [blame] | 878 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 879 | salt.enforceStateWithTest([saltId: master, target: "I@elasticsearch:server:enabled:true ${extra_tgt}", state: 'elasticsearch.server']) |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 880 | if (salt.testTarget(master, "I@kibana:server:enabled:true ${extra_tgt}")) { |
| 881 | first_target = salt.getFirstMinion(master, "I@kibana:server:enabled:true ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 882 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'kibana.server']) |
Ramon Melero | ae6e16a | 2018-08-07 13:42:16 -0500 | [diff] [blame] | 883 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 884 | salt.enforceStateWithTest([saltId: master, target: "I@kibana:server:enabled:true ${extra_tgt}", state: 'kibana.server']) |
Martin Polreich | 675dc94 | 2018-08-15 09:37:32 +0200 | [diff] [blame] | 885 | |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 886 | // Check ES health cluster status |
Dmitry Kalashnik | 73e43a4 | 2019-05-27 15:44:17 +0400 | [diff] [blame] | 887 | def pillar = salt.getReturnValues(salt.getPillar(master, "I@elasticsearch:client ${extra_tgt}", 'elasticsearch:client:server:host')) |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 888 | def elasticsearch_vip |
Dmitry Kalashnik | b34cb7c | 2019-05-27 16:38:03 +0400 | [diff] [blame] | 889 | if(pillar) { |
Dmitry Kalashnik | 73e43a4 | 2019-05-27 15:44:17 +0400 | [diff] [blame] | 890 | elasticsearch_vip = pillar |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 891 | } else { |
| 892 | common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| 893 | } |
Dmitry Kalashnik | 73e43a4 | 2019-05-27 15:44:17 +0400 | [diff] [blame] | 894 | |
| 895 | pillar = salt.getReturnValues(salt.getPillar(master, "I@elasticsearch:client ${extra_tgt}", 'elasticsearch:client:server:port')) |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 896 | def elasticsearch_port |
Dmitry Kalashnik | b34cb7c | 2019-05-27 16:38:03 +0400 | [diff] [blame] | 897 | if(pillar) { |
Dmitry Kalashnik | 73e43a4 | 2019-05-27 15:44:17 +0400 | [diff] [blame] | 898 | elasticsearch_port = pillar |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 899 | } else { |
| 900 | common.errorMsg('[ERROR] Elasticsearch VIP port could not be retrieved') |
| 901 | } |
Dmitry Kalashnik | 73e43a4 | 2019-05-27 15:44:17 +0400 | [diff] [blame] | 902 | |
| 903 | pillar = salt.getReturnValues(salt.getPillar(master, "I@elasticsearch:client ${extra_tgt}", 'elasticsearch:client:server:scheme')) |
Dmitry Kalashnik | 22b03e8 | 2019-05-23 10:06:28 +0400 | [diff] [blame] | 904 | def elasticsearch_scheme |
Dmitry Kalashnik | b34cb7c | 2019-05-27 16:38:03 +0400 | [diff] [blame] | 905 | if(pillar) { |
Dmitry Kalashnik | 73e43a4 | 2019-05-27 15:44:17 +0400 | [diff] [blame] | 906 | elasticsearch_scheme = pillar |
| 907 | common.infoMsg("[INFO] Using elasticsearch scheme: ${elasticsearch_scheme}") |
Dmitry Kalashnik | 22b03e8 | 2019-05-23 10:06:28 +0400 | [diff] [blame] | 908 | } else { |
Dmitry Kalashnik | 73e43a4 | 2019-05-27 15:44:17 +0400 | [diff] [blame] | 909 | common.infoMsg('[INFO] No pillar with Elasticsearch server scheme, using scheme: http') |
Dmitry Kalashnik | 22b03e8 | 2019-05-23 10:06:28 +0400 | [diff] [blame] | 910 | elasticsearch_scheme = "http" |
| 911 | } |
| 912 | |
Martin Polreich | 331f2b6 | 2019-02-08 10:16:52 +0100 | [diff] [blame] | 913 | common.retry(step_retries,step_retries_wait) { |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 914 | common.infoMsg('Waiting for Elasticsearch to become green..') |
Dmitry Kalashnik | 22b03e8 | 2019-05-23 10:06:28 +0400 | [diff] [blame] | 915 | salt.cmdRun(master, "I@elasticsearch:client ${extra_tgt}", "curl -skf ${elasticsearch_scheme}://${elasticsearch_vip}:${elasticsearch_port}/_cat/health | awk '{print \$4}' | grep green") |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 916 | } |
| 917 | |
Martin Polreich | 331f2b6 | 2019-02-08 10:16:52 +0100 | [diff] [blame] | 918 | salt.enforceState([saltId: master, target: "I@elasticsearch:client ${extra_tgt}", state: 'elasticsearch.client', retries: step_retries, retries_wait: step_retries_wait]) |
Mateusz Matuszkowiak | 018a390 | 2018-06-06 11:54:15 +0200 | [diff] [blame] | 919 | |
Martin Polreich | 331f2b6 | 2019-02-08 10:16:52 +0100 | [diff] [blame] | 920 | salt.enforceState([saltId: master, target: "I@kibana:client ${extra_tgt}", state: 'kibana.client', retries: step_retries, retries_wait: step_retries_wait]) |
Dmitry Kalashnik | 53feda7 | 2018-03-16 16:06:10 +0400 | [diff] [blame] | 921 | |
| 922 | //Install InfluxDB |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 923 | if (salt.testTarget(master, "I@influxdb:server ${extra_tgt}")) { |
Dmitry Ukov | 8d50e18 | 2018-08-27 17:25:34 +0400 | [diff] [blame] | 924 | first_target = salt.getFirstMinion(master, "I@influxdb:server ${extra_tgt}") |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 925 | salt.enforceState([saltId: master, target: "${first_target} ${extra_tgt}", state: 'influxdb']) |
| 926 | salt.enforceState([saltId: master, target: "I@influxdb:server ${extra_tgt}", state: 'influxdb']) |
Dmitry Kalashnik | 53feda7 | 2018-03-16 16:06:10 +0400 | [diff] [blame] | 927 | } |
| 928 | |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 929 | // Install service for the log collection |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 930 | if (salt.testTarget(master, "I@fluentd:agent ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 931 | salt.enforceState([saltId: master, target: "I@fluentd:agent ${extra_tgt}", state: 'fluentd']) |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 932 | } else { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 933 | salt.enforceState([saltId: master, target: "I@heka:log_collector ${extra_tgt}", state: 'heka.log_collector']) |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 934 | } |
Simon Pasquier | 6301ddd | 2017-09-05 11:56:58 +0200 | [diff] [blame] | 935 | |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 936 | // Install heka ceilometer collector |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 937 | if (salt.testTarget(master, "I@heka:ceilometer_collector:enabled ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 938 | salt.enforceState([saltId: master, target: "I@heka:ceilometer_collector:enabled ${extra_tgt}", state: 'heka.ceilometer_collector']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 939 | 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] | 940 | } |
| 941 | |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 942 | // Install galera |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 943 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 944 | salt.enforceState([saltId: master, target: "I@galera:master ${extra_tgt}", state: 'galera', retries: 2]) |
| 945 | salt.enforceState([saltId: master, target: "I@galera:slave ${extra_tgt}", state: 'galera', retries: 2]) |
Martin Polreich | 406f646 | 2017-07-11 11:33:42 +0000 | [diff] [blame] | 946 | |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 947 | // Check galera status |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 948 | salt.runSaltProcessStep(master, "I@galera:master ${extra_tgt}", 'mysql.status') |
| 949 | salt.runSaltProcessStep(master, "I@galera:slave ${extra_tgt}", 'mysql.status') |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 950 | } |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 951 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 952 | //Collect Grains |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 953 | salt.enforceState([saltId: master, target: "I@salt:minion ${extra_tgt}", state: 'salt.minion.grains']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 954 | salt.runSaltProcessStep(master, "I@salt:minion ${extra_tgt}", 'saltutil.refresh_modules') |
| 955 | salt.runSaltProcessStep(master, "I@salt:minion ${extra_tgt}", 'mine.update') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 956 | sleep(5) |
| 957 | |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 958 | // Configure Prometheus in Docker Swarm |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 959 | salt.enforceState([saltId: master, target: "I@docker:swarm and I@prometheus:server ${extra_tgt}", state: 'prometheus']) |
Ildar Svetlov | 794f89e | 2018-02-14 16:28:53 +0400 | [diff] [blame] | 960 | |
Ildar Svetlov | 0eec97d | 2018-02-15 10:06:40 +0400 | [diff] [blame] | 961 | //Configure Remote Collector in Docker Swarm for Openstack deployments |
Dmitry Kalashnik | b7f023a | 2019-05-27 20:01:37 +0400 | [diff] [blame] | 962 | if (salt.testTarget(master, "I@heka:remote_collector ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 963 | salt.enforceState([saltId: master, target: "I@docker:swarm and I@prometheus:server ${extra_tgt}", state: 'heka.remote_collector', failOnError: false]) |
Martin Polreich | 8017f45 | 2017-08-21 16:01:42 +0200 | [diff] [blame] | 964 | } |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 965 | |
Ildar Svetlov | 225fb6c | 2018-06-06 14:59:31 +0400 | [diff] [blame] | 966 | // Launch containers |
Ivan Berezovskiy | e59448c | 2018-12-25 18:47:29 +0400 | [diff] [blame] | 967 | // Pull images first if any |
| 968 | def listMinions = salt.getMinions(master, "I@docker:swarm and I@prometheus:server ${extra_tgt}") |
| 969 | for (int i = 0; i < listMinions.size(); i++) { |
| 970 | if (!salt.getReturnValues(salt.getPillar(master, listMinions[i], 'docker:client:images')).isEmpty()) { |
| 971 | salt.enforceState([saltId: master, target: listMinions[i], state: 'docker.client.images', retries: 2]) |
| 972 | } |
| 973 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 974 | salt.enforceState([saltId: master, target: "I@docker:swarm:role:master and I@prometheus:server ${extra_tgt}", state: 'docker.client']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 975 | 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] | 976 | |
| 977 | //Install Prometheus LTS |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 978 | salt.enforceStateWithTest([saltId: master, target: "I@prometheus:relay ${extra_tgt}", state: 'prometheus']) |
Ildar Svetlov | 225fb6c | 2018-06-06 14:59:31 +0400 | [diff] [blame] | 979 | |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 980 | // Install sphinx server |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 981 | salt.enforceStateWithTest([saltId: master, target: "I@sphinx:server ${extra_tgt}", state: 'sphinx']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 982 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 983 | //Configure Grafana |
Denis Egorenko | 8006cce | 2019-08-26 13:16:23 +0400 | [diff] [blame] | 984 | pillar = salt.getPillar(master, "I@keystone:server:role:primary ${extra_tgt}", '_param:stacklight_monitor_address') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 985 | common.prettyPrint(pillar) |
Martin Polreich | 595baef | 2017-07-04 16:11:04 +0200 | [diff] [blame] | 986 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 987 | def stacklight_vip |
| 988 | if(!pillar['return'].isEmpty()) { |
| 989 | stacklight_vip = pillar['return'][0].values()[0] |
| 990 | } else { |
| 991 | common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved') |
| 992 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 993 | |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 994 | common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start") |
Martin Polreich | bd7ad22 | 2017-07-06 12:53:51 +0200 | [diff] [blame] | 995 | sleep(120) |
Mateusz Matuszkowiak | 0a6f9b5 | 2019-05-07 11:23:52 +0200 | [diff] [blame] | 996 | |
| 997 | salt.enforceState([saltId: master, target: "I@grafana:client ${extra_tgt}", state: 'grafana.client', retries: step_retries, retries_wait: step_retries_wait]) |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 998 | } |
| 999 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1000 | def installStacklightv1Control(master, extra_tgt = '') { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 1001 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1002 | |
| 1003 | // infra install |
| 1004 | // Install the StackLight backends |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1005 | salt.enforceState([saltId: master, target: "*01* and I@elasticsearch:server ${extra_tgt}", state: 'elasticsearch.server']) |
| 1006 | salt.enforceState([saltId: master, target: "I@elasticsearch:server ${extra_tgt}", state: 'elasticsearch.server']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1007 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1008 | salt.enforceState([saltId: master, target: "*01* and I@influxdb:server ${extra_tgt}", state: 'influxdb']) |
| 1009 | salt.enforceState([saltId: master, target: "I@influxdb:server ${extra_tgt}", state: 'influxdb']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1010 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1011 | salt.enforceState([saltId: master, target: "*01* and I@kibana:server ${extra_tgt}", state: 'kibana.server']) |
| 1012 | salt.enforceState([saltId: master, target: "I@kibana:server ${extra_tgt}", state: 'kibana.server']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1013 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1014 | salt.enforceState([saltId: master, target: "*01* and I@grafana:server ${extra_tgt}",state: 'grafana.server']) |
| 1015 | salt.enforceState([saltId: master, target: "I@grafana:server ${extra_tgt}", state: 'grafana.server']) |
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] |
| 1019 | |
| 1020 | switch (alarming_service) { |
| 1021 | case 'sensu': |
| 1022 | // Update Sensu |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1023 | salt.enforceState([saltId: master, target: "I@sensu:server and I@rabbitmq:server ${extra_tgt}", state: 'rabbitmq']) |
| 1024 | salt.enforceState([saltId: master, target: "I@redis:cluster:role:master ${extra_tgt}", state: 'redis']) |
| 1025 | salt.enforceState([saltId: master, target: "I@redis:server ${extra_tgt}", state: 'redis']) |
| 1026 | salt.enforceState([saltId: master, target: "I@sensu:server ${extra_tgt}", state: 'sensu']) |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 1027 | default: |
| 1028 | // Update Nagios |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1029 | salt.enforceState([saltId: master, target: "I@nagios:server ${extra_tgt}", state: 'nagios.server']) |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 1030 | // Stop the Nagios service because the package starts it by default and it will |
| 1031 | // started later only on the node holding the VIP address |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1032 | salt.runSaltProcessStep(master, "I@nagios:server ${extra_tgt}", 'service.stop', ['nagios3'], null, true) |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 1033 | } |
| 1034 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1035 | salt.enforceState([saltId: master, target: "I@elasticsearch:client ${extra_tgt}", state: 'elasticsearch.client.service']) |
| 1036 | salt.enforceState([saltId: master, target: "I@kibana:client ${extra_tgt}", state: 'kibana.client']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1037 | |
| 1038 | sleep(10) |
| 1039 | } |
| 1040 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1041 | def installStacklightv1Client(master, extra_tgt = '') { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 1042 | def salt = new com.mirantis.mk.Salt() |
| 1043 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1044 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1045 | salt.cmdRun(master, "I@elasticsearch:client ${extra_tgt}", 'salt-call state.sls elasticsearch.client') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1046 | // salt.enforceState([saltId: master, target: "I@elasticsearch:client", state: 'elasticsearch.client", true]) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1047 | salt.cmdRun(master, "I@kibana:client ${extra_tgt}", 'salt-call state.sls kibana.client') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1048 | // salt.enforceState([saltId: master, target: "I@kibana:client", state: 'kibana.client", true]) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1049 | |
| 1050 | // Install collectd, heka and sensu services on the nodes, this will also |
| 1051 | // generate the metadata that goes into the grains and eventually into Salt Mine |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1052 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: 'collectd']) |
azvyagintsev | e9beda3 | 2019-06-07 15:20:52 +0300 | [diff] [blame] | 1053 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: 'salt.minion', retries: 2]) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1054 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: 'heka']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1055 | |
| 1056 | // Gather the Grafana metadata as grains |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1057 | salt.enforceState([saltId: master, target: "I@grafana:collector ${extra_tgt}", state: 'grafana.collector']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1058 | |
| 1059 | // Update Salt Mine |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1060 | salt.enforceState([saltId: master, target: "* ${extra_tgt}", state: 'salt.minion.grains']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1061 | salt.runSaltProcessStep(master, "* ${extra_tgt}", 'saltutil.refresh_modules') |
| 1062 | salt.runSaltProcessStep(master, "* ${extra_tgt}", 'mine.update') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1063 | |
| 1064 | sleep(5) |
| 1065 | |
| 1066 | // Update Heka |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1067 | salt.enforceState([saltId: master, target: "( I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True ) ${extra_tgt}", state: 'heka']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1068 | |
| 1069 | // Update collectd |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1070 | salt.enforceState([saltId: master, target: "I@collectd:remote_client:enabled:True ${extra_tgt}", state: 'collectd']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1071 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1072 | 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] | 1073 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1074 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 1075 | switch (alarming_service) { |
| 1076 | case 'sensu': |
| 1077 | // Update Sensu |
| 1078 | // TODO for stacklight team, should be fixed in model |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1079 | salt.enforceState([saltId: master, target: "I@sensu:client ${extra_tgt}", state: 'sensu']) |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 1080 | default: |
| 1081 | break |
| 1082 | // Default is nagios, and was enforced in installStacklightControl() |
| 1083 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1084 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1085 | salt.cmdRun(master, "I@grafana:client and *01* ${extra_tgt}", 'salt-call state.sls grafana.client') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1086 | // salt.enforceState([saltId: master, target: "I@grafana:client and *01*", state: 'grafana.client"]) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1087 | |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 1088 | // Finalize the configuration of Grafana (add the dashboards...) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1089 | salt.enforceState([saltId: master, target: "I@grafana:client and *01* ${extra_tgt}", state: 'grafana.client']) |
| 1090 | salt.enforceState([saltId: master, target: "I@grafana:client and *02* ${extra_tgt}", state: 'grafana.client']) |
| 1091 | salt.enforceState([saltId: master, target: "I@grafana:client and *03* ${extra_tgt}", state: 'grafana.client']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1092 | // 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] | 1093 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1094 | // Get the StackLight monitoring VIP addres |
| 1095 | //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 1096 | //vip=${vip:=172.16.10.253} |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1097 | def pillar = salt.getPillar(master, "ctl01* ${extra_tgt}", '_param:stacklight_monitor_address') |
Jakub Josef | bceaa32 | 2017-06-13 18:28:27 +0200 | [diff] [blame] | 1098 | common.prettyPrint(pillar) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1099 | def stacklight_vip = pillar['return'][0].values()[0] |
| 1100 | |
| 1101 | if (stacklight_vip) { |
| 1102 | // (re)Start manually the services that are bound to the monitoring VIP |
| 1103 | common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1104 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip} ${extra_tgt}", 'service.restart', ['remote_collectd']) |
| 1105 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip} ${extra_tgt}", 'service.restart', ['remote_collector']) |
| 1106 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip} ${extra_tgt}", 'service.restart', ['aggregator']) |
| 1107 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip} ${extra_tgt}", 'service.restart', ['nagios3']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 1108 | } else { |
| 1109 | throw new Exception("Missing stacklight_vip") |
| 1110 | } |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 1111 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1112 | |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1113 | // |
| 1114 | // backups |
| 1115 | // |
| 1116 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1117 | def installBackup(master, component='common', extra_tgt = '') { |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1118 | def salt = new com.mirantis.mk.Salt() |
| 1119 | if (component == 'common') { |
| 1120 | // Install Backupninja |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1121 | if (salt.testTarget(master, "I@backupninja:client ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1122 | salt.enforceState([saltId: master, target: "I@backupninja:client ${extra_tgt}", state: 'salt.minion.grains']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1123 | salt.runSaltProcessStep(master, "I@backupninja:client ${extra_tgt}", 'saltutil.sync_grains') |
| 1124 | salt.runSaltProcessStep(master, "I@backupninja:client ${extra_tgt}", 'mine.flush') |
| 1125 | salt.runSaltProcessStep(master, "I@backupninja:client ${extra_tgt}", 'mine.update') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1126 | salt.enforceState([saltId: master, target: "I@backupninja:client ${extra_tgt}", state: 'backupninja']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1127 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1128 | salt.enforceStateWithTest([saltId: master, target: "I@backupninja:server ${extra_tgt}", state: 'salt.minion.grains']) |
| 1129 | salt.enforceStateWithTest([saltId: master, target: "I@backupninja:server ${extra_tgt}", state: 'backupninja']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1130 | } else if (component == 'mysql') { |
| 1131 | // Install Xtrabackup |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1132 | if (salt.testTarget(master, "I@xtrabackup:client ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1133 | salt.enforceState([saltId: master, target: "I@xtrabackup:client ${extra_tgt}", state: 'salt.minion.grains']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1134 | salt.runSaltProcessStep(master, "I@xtrabackup:client ${extra_tgt}", 'saltutil.sync_grains') |
| 1135 | salt.runSaltProcessStep(master, "I@xtrabackup:client ${extra_tgt}", 'mine.flush') |
| 1136 | salt.runSaltProcessStep(master, "I@xtrabackup:client ${extra_tgt}", 'mine.update') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1137 | salt.enforceState([saltId: master, target: "I@xtrabackup:client ${extra_tgt}", state: 'xtrabackup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1138 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1139 | salt.enforceStateWithTest([saltId: master, target: "I@xtrabackup:server ${extra_tgt}", state: 'xtrabackup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1140 | } else if (component == 'contrail') { |
| 1141 | |
| 1142 | // Install Cassandra backup |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1143 | if (salt.testTarget(master, "I@cassandra:backup:client ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1144 | salt.enforceState([saltId: master, target: "I@cassandra:backup:client ${extra_tgt}", state: 'salt.minion.grains']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1145 | salt.runSaltProcessStep(master, "I@cassandra:backup:client ${extra_tgt}", 'saltutil.sync_grains') |
| 1146 | salt.runSaltProcessStep(master, "I@cassandra:backup:client ${extra_tgt}", 'mine.flush') |
| 1147 | salt.runSaltProcessStep(master, "I@cassandra:backup:client ${extra_tgt}", 'mine.update') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1148 | salt.enforceState([saltId: master, target: "I@cassandra:backup:client ${extra_tgt}", state: 'cassandra.backup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1149 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1150 | salt.enforceStateWithTest([saltId: master, target: "I@cassandra:backup:server ${extra_tgt}", state: 'cassandra.backup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1151 | // Install Zookeeper backup |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1152 | if (salt.testTarget(master, "I@zookeeper:backup:client ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1153 | salt.enforceState([saltId: master, target: "I@zookeeper:backup:client ${extra_tgt}", state: 'salt.minion.grains']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1154 | salt.runSaltProcessStep(master, "I@zookeeper:backup:client ${extra_tgt}", 'saltutil.sync_grains') |
| 1155 | salt.runSaltProcessStep(master, "I@zookeeper:backup:client ${extra_tgt}", 'mine.flush') |
| 1156 | salt.runSaltProcessStep(master, "I@zookeeper:backup:client ${extra_tgt}", 'mine.update') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1157 | salt.enforceState([saltId: master, target: "I@zookeeper:backup:client ${extra_tgt}", state: 'zookeeper.backup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1158 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1159 | salt.enforceStateWithTest([saltId: master, target: "I@zookeeper:backup:server ${extra_tgt}", state: 'zookeeper.backup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1160 | } else if (component == 'ceph') { |
| 1161 | // Install Ceph backup |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1162 | if (salt.testTarget(master, "I@ceph:backup:client ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1163 | salt.enforceState([saltId: master, target: "I@ceph:backup:client ${extra_tgt}", state: 'salt.minion.grains']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1164 | salt.runSaltProcessStep(master, "I@ceph:backup:client ${extra_tgt}", 'saltutil.sync_grains') |
| 1165 | salt.runSaltProcessStep(master, "I@ceph:backup:client ${extra_tgt}", 'mine.flush') |
| 1166 | salt.runSaltProcessStep(master, "I@ceph:backup:client ${extra_tgt}", 'mine.update') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1167 | salt.enforceState([saltId: master, target: "I@ceph:backup:client ${extra_tgt}", state: 'ceph.backup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1168 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1169 | salt.enforceStateWithTest([saltId: master, target: "I@ceph:backup:server ${extra_tgt}", state: 'ceph.backup']) |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1173 | |
| 1174 | // |
| 1175 | // Ceph |
| 1176 | // |
| 1177 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1178 | def installCephMon(master, target="I@ceph:mon", extra_tgt = '') { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1179 | def salt = new com.mirantis.mk.Salt() |
| 1180 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1181 | salt.enforceState([saltId: master, target: "I@ceph:common ${extra_tgt}", state: 'salt.minion.grains']) |
Jiri Broulik | bfc234f | 2017-10-17 15:45:38 +0200 | [diff] [blame] | 1182 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1183 | // generate keyrings |
Martin Polreich | 4433100 | 2018-08-13 11:27:06 +0200 | [diff] [blame] | 1184 | if (salt.testTarget(master, "( I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin ) ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1185 | salt.enforceState([saltId: master, target: "( I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin ) ${extra_tgt}", state: 'ceph.mon']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1186 | salt.runSaltProcessStep(master, "I@ceph:mon ${extra_tgt}", 'saltutil.sync_grains') |
Martin Polreich | 4433100 | 2018-08-13 11:27:06 +0200 | [diff] [blame] | 1187 | salt.runSaltProcessStep(master, "( I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin ) ${extra_tgt}", 'mine.update') |
Vasyl Saienko | 03ed4e7 | 2018-11-14 11:35:29 +0200 | [diff] [blame] | 1188 | |
| 1189 | // on target nodes mine is used to get pillar from 'ceph:common:keyring:admin' via grain.items |
| 1190 | // we need to refresh all pillar/grains to make data sharing work correctly |
| 1191 | salt.fullRefresh(master, "( I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin ) ${extra_tgt}") |
| 1192 | |
Jiri Broulik | 3c75a6d | 2017-10-06 18:44:37 +0200 | [diff] [blame] | 1193 | sleep(5) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1194 | } |
Ondrej Smola | fd5c235 | 2017-08-11 14:25:39 +0200 | [diff] [blame] | 1195 | // install Ceph Mons |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1196 | salt.enforceState([saltId: master, target: target, state: 'ceph.mon']) |
| 1197 | salt.enforceStateWithTest([saltId: master, target: "I@ceph:mgr ${extra_tgt}", state: 'ceph.mgr']) |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1198 | } |
| 1199 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1200 | def installCephOsd(master, target="I@ceph:osd", setup=true, extra_tgt = '') { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1201 | def salt = new com.mirantis.mk.Salt() |
| 1202 | |
| 1203 | // install Ceph OSDs |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1204 | salt.enforceState([saltId: master, target: target, state: 'ceph.osd']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1205 | salt.runSaltProcessStep(master, "I@ceph:osd ${extra_tgt}", 'saltutil.sync_grains') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1206 | salt.enforceState([saltId: master, target: target, state: 'ceph.osd.custom']) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1207 | salt.runSaltProcessStep(master, "I@ceph:osd ${extra_tgt}", 'saltutil.sync_grains') |
| 1208 | salt.runSaltProcessStep(master, "I@ceph:osd ${extra_tgt}", 'mine.update') |
Jiri Broulik | e3e7bc3 | 2018-02-26 10:50:07 +0100 | [diff] [blame] | 1209 | installBackup(master, 'ceph') |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 1210 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1211 | // setup pools, keyrings and maybe crush |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1212 | if (salt.testTarget(master, "I@ceph:setup ${extra_tgt}") && setup) { |
Jiri Broulik | 07f8de7 | 2017-10-09 14:12:17 +0200 | [diff] [blame] | 1213 | sleep(5) |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1214 | salt.enforceState([saltId: master, target: "I@ceph:setup ${extra_tgt}", state: 'ceph.setup']) |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 1215 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 1216 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 1217 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1218 | def installCephClient(master, extra_tgt = '') { |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 1219 | def salt = new com.mirantis.mk.Salt() |
| 1220 | |
| 1221 | // install Ceph Radosgw |
Mykyta Karpin | f7a714c | 2018-11-06 14:22:36 +0200 | [diff] [blame] | 1222 | if (salt.testTarget(master, "I@ceph:radosgw ${extra_tgt}")) { |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1223 | salt.runSaltProcessStep(master, "I@ceph:radosgw ${extra_tgt}", 'saltutil.sync_grains') |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1224 | salt.enforceState([saltId: master, target: "I@ceph:radosgw ${extra_tgt}", state: 'ceph.radosgw']) |
Alexander Noskov | 229035f | 2017-12-06 00:10:20 +0400 | [diff] [blame] | 1225 | } |
Mykyta Karpin | 9b8beab | 2018-09-11 17:52:35 +0300 | [diff] [blame] | 1226 | |
| 1227 | // setup keyring for Openstack services |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1228 | salt.enforceStateWithTest([saltId: master, target: "I@ceph:common and I@glance:server ${extra_tgt}", state: ['ceph.common', 'ceph.setup.keyring']]) |
Mykyta Karpin | 9b8beab | 2018-09-11 17:52:35 +0300 | [diff] [blame] | 1229 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1230 | salt.enforceStateWithTest([saltId: master, target: "I@ceph:common and I@cinder:controller ${extra_tgt}", state: ['ceph.common', 'ceph.setup.keyring']]) |
Mykyta Karpin | 9b8beab | 2018-09-11 17:52:35 +0300 | [diff] [blame] | 1231 | |
| 1232 | if (salt.testTarget(master, "I@ceph:common and I@nova:compute ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1233 | salt.enforceState([saltId: master, target: "I@ceph:common and I@nova:compute ${extra_tgt}", state: ['ceph.common', 'ceph.setup.keyring']]) |
Mykyta Karpin | 9b8beab | 2018-09-11 17:52:35 +0300 | [diff] [blame] | 1234 | salt.runSaltProcessStep(master, "I@ceph:common and I@nova:compute ${extra_tgt}", 'saltutil.sync_grains') |
| 1235 | } |
| 1236 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1237 | salt.enforceStateWithTest([saltId: master, target: "I@ceph:common and I@gnocchi:server ${extra_tgt}", state: ['ceph.common', 'ceph.setup.keyring']]) |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 1238 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1239 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1240 | def connectCeph(master, extra_tgt = '') { |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1241 | def salt = new com.mirantis.mk.Salt() |
| 1242 | |
Mykyta Karpin | 9b8beab | 2018-09-11 17:52:35 +0300 | [diff] [blame] | 1243 | // setup Keystone service and endpoints for swift or / and S3 |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1244 | salt.enforceStateWithTest([saltId: master, target: "I@keystone:client ${extra_tgt}", state: 'keystone.client']) |
Mykyta Karpin | 9b8beab | 2018-09-11 17:52:35 +0300 | [diff] [blame] | 1245 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1246 | // connect Ceph to the env |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1247 | if (salt.testTarget(master, "I@ceph:common and I@glance:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1248 | salt.enforceState([saltId: master, target: "I@ceph:common and I@glance:server ${extra_tgt}", state: ['glance']]) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1249 | 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] | 1250 | } |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1251 | if (salt.testTarget(master, "I@ceph:common and I@cinder:controller ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1252 | salt.enforceState([saltId: master, target: "I@ceph:common and I@cinder:controller ${extra_tgt}", state: ['cinder']]) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1253 | 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] | 1254 | } |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1255 | if (salt.testTarget(master, "I@ceph:common and I@nova:compute ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1256 | salt.enforceState([saltId: master, target: "I@ceph:common and I@nova:compute ${extra_tgt}", state: ['nova']]) |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1257 | 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] | 1258 | } |
Mykyta Karpin | 0dec8b3 | 2018-09-19 09:37:45 +0300 | [diff] [blame] | 1259 | if (salt.testTarget(master, "I@ceph:common and I@gnocchi:server ${extra_tgt}")) { |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1260 | salt.enforceState([saltId: master, target: "I@ceph:common and I@gnocchi:server:role:primary ${extra_tgt}", state: 'gnocchi.server']) |
| 1261 | salt.enforceState([saltId: master, target: "I@ceph:common and I@gnocchi:server ${extra_tgt}", state: 'gnocchi.server']) |
Mykyta Karpin | 0dec8b3 | 2018-09-19 09:37:45 +0300 | [diff] [blame] | 1262 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 1263 | } |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1264 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1265 | def installOssInfra(master, extra_tgt = '') { |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1266 | def common = new com.mirantis.mk.Common() |
| 1267 | def salt = new com.mirantis.mk.Salt() |
| 1268 | |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1269 | salt.enforceStateWithTest([saltId: master, target: "I@devops_portal:config ${extra_tgt}", state: 'devops_portal.config']) |
| 1270 | salt.enforceStateWithTest([saltId: master, target: "I@rundeck:client ${extra_tgt}", state: ['linux.system.user', 'openssh'], testTargetMatcher: "I@devops_portal:config ${extra_tgt}"]) |
| 1271 | salt.enforceStateWithTest([saltId: master, target: "I@rundeck:server ${extra_tgt}", state: 'rundeck.server', testTargetMatcher: "I@devops_portal:config ${extra_tgt}"]) |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1272 | } |
| 1273 | |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1274 | def installOss(master, extra_tgt = '') { |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1275 | def common = new com.mirantis.mk.Common() |
| 1276 | def salt = new com.mirantis.mk.Salt() |
| 1277 | |
| 1278 | //Get oss VIP address |
Denis Egorenko | 8006cce | 2019-08-26 13:16:23 +0400 | [diff] [blame] | 1279 | def pillar = salt.getPillar(master, "I@salt:master ${extra_tgt}", '_param:stacklight_monitor_address') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1280 | common.prettyPrint(pillar) |
| 1281 | |
| 1282 | def oss_vip |
| 1283 | if(!pillar['return'].isEmpty()) { |
| 1284 | oss_vip = pillar['return'][0].values()[0] |
| 1285 | } else { |
| 1286 | common.errorMsg('[ERROR] Oss VIP address could not be retrieved') |
| 1287 | } |
| 1288 | |
| 1289 | // Postgres client - initialize OSS services databases |
| 1290 | timeout(120){ |
| 1291 | common.infoMsg("Waiting for postgresql database to come up..") |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1292 | 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] | 1293 | } |
| 1294 | // XXX: first run usually fails on some inserts, but we need to create databases at first |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1295 | salt.enforceState([saltId: master, target: "I@postgresql:client ${extra_tgt}", state: 'postgresql.client', failOnError: false]) |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1296 | |
| 1297 | // Setup postgres database with integration between |
| 1298 | // Pushkin notification service and Security Monkey security audit service |
| 1299 | timeout(10) { |
| 1300 | common.infoMsg("Waiting for Pushkin to come up..") |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1301 | 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] | 1302 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1303 | salt.enforceState([saltId: master, target: "I@postgresql:client ${extra_tgt}", state: 'postgresql.client']) |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1304 | |
| 1305 | // Rundeck |
| 1306 | timeout(10) { |
| 1307 | common.infoMsg("Waiting for Rundeck to come up..") |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1308 | 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] | 1309 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1310 | salt.enforceState([saltId: master, target: "I@rundeck:client ${extra_tgt}", state: 'rundeck.client']) |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1311 | |
| 1312 | // Elasticsearch |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1313 | 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] | 1314 | def elasticsearch_vip |
| 1315 | if(!pillar['return'].isEmpty()) { |
| 1316 | elasticsearch_vip = pillar['return'][0].values()[0] |
| 1317 | } else { |
| 1318 | common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| 1319 | } |
| 1320 | |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1321 | timeout(10) { |
| 1322 | common.infoMsg('Waiting for Elasticsearch to come up..') |
Oleh Hryhorov | 5f96e09 | 2018-06-22 18:37:08 +0300 | [diff] [blame] | 1323 | 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] | 1324 | } |
Martin Polreich | 80fa318 | 2018-10-22 15:16:53 +0200 | [diff] [blame] | 1325 | salt.enforceState([saltId: master, target: "I@elasticsearch:client ${extra_tgt}", state: 'elasticsearch.client']) |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 1326 | } |
Oleksii Grudev | 9e1d97a | 2018-06-29 16:04:30 +0300 | [diff] [blame] | 1327 | |
| 1328 | /** |
| 1329 | * Function receives connection string, target and configuration yaml pattern |
| 1330 | * and retrieves config fom salt minion according to pattern. After that it |
| 1331 | * sorts applications according to priorities and runs orchestration states |
| 1332 | * @param master Salt Connection object or pepperEnv |
| 1333 | * @param tgt Target |
| 1334 | * @param conf Configuration pattern |
| 1335 | */ |
| 1336 | def OrchestrateApplications(master, tgt, conf) { |
| 1337 | def salt = new com.mirantis.mk.Salt() |
| 1338 | def common = new com.mirantis.mk.Common() |
| 1339 | def _orch = salt.getConfig(master, tgt, conf) |
| 1340 | if ( !_orch['return'][0].values()[0].isEmpty() ) { |
| 1341 | Map<String,Integer> _orch_app = [:] |
| 1342 | for (k in _orch['return'][0].values()[0].keySet()) { |
| 1343 | _orch_app[k] = _orch['return'][0].values()[0][k].values()[0].toInteger() |
| 1344 | } |
| 1345 | def _orch_app_sorted = common.SortMapByValueAsc(_orch_app) |
| 1346 | common.infoMsg("Applications will be deployed in following order:"+_orch_app_sorted.keySet()) |
| 1347 | for (app in _orch_app_sorted.keySet()) { |
| 1348 | salt.orchestrateSystem(master, ['expression': tgt, 'type': 'compound'], "${app}.orchestrate.deploy") |
| 1349 | } |
| 1350 | } |
| 1351 | else { |
| 1352 | common.infoMsg("No applications found for orchestration") |
| 1353 | } |
Inessa Vasilevskaya | 85ad1a9 | 2018-10-08 12:19:47 +0200 | [diff] [blame] | 1354 | } |