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