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