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