Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 1 | package com.mirantis.mk |
| 2 | /** |
| 3 | * Orchestration functions |
| 4 | * |
| 5 | */ |
| 6 | |
| 7 | def validateFoundationInfra(master) { |
| 8 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 9 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 10 | salt.cmdRun(master, 'I@salt:master' ,'salt-key') |
| 11 | salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version') |
| 12 | salt.cmdRun(master, 'I@salt:master' ,'reclass-salt --top') |
| 13 | salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory') |
| 14 | salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 15 | } |
| 16 | |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 17 | def installFoundationInfra(master, staticMgmtNet=false) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 18 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 19 | |
Vasyl Saienko | 0869b3a | 2017-11-22 14:37:57 +0200 | [diff] [blame] | 20 | // NOTE(vsaienko) Apply reclass first, it may update cluster model |
| 21 | // apply linux and salt.master salt.minion states afterwards to make sure |
| 22 | // correct cluster model is used. |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 23 | salt.enforceState(master, 'I@salt:master', ['reclass']) |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 24 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 25 | salt.enforceState(master, 'I@salt:master', ['linux.system']) |
Vasyl Saienko | 0869b3a | 2017-11-22 14:37:57 +0200 | [diff] [blame] | 26 | salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 27 | salt.fullRefresh(master, "*") |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 28 | |
Vasyl Saienko | e36ab7c | 2017-07-17 14:35:48 +0300 | [diff] [blame] | 29 | salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 30 | salt.enforceState(master, 'I@salt:master', ['salt.minion']) |
| 31 | salt.fullRefresh(master, "*") |
Tomáš Kukrál | b4d7522 | 2017-06-06 10:36:02 +0200 | [diff] [blame] | 32 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 33 | salt.enforceState(master, '*', ['linux.system']) |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 34 | if (staticMgmtNet) { |
| 35 | salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| 36 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 37 | salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp']) |
Tomáš Kukrál | 7e767f9 | 2017-08-18 14:53:17 +0200 | [diff] [blame] | 38 | salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2) |
Jakub Josef | 4f8f4df | 2017-09-01 14:32:42 +0200 | [diff] [blame] | 39 | sleep(5) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 40 | salt.enforceState(master, '*', ['linux.network.host']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 41 | } |
| 42 | |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 43 | def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) { |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 44 | def salt = new com.mirantis.mk.Salt() |
| 45 | |
| 46 | salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 47 | salt.fullRefresh(master, target) |
| 48 | salt.enforceState(master, target, ['linux.system']) |
Jiri Broulik | 8e1f1fe | 2017-12-13 11:54:06 +0100 | [diff] [blame] | 49 | if (staticMgmtNet) { |
| 50 | salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| 51 | } |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 52 | salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 53 | salt.enforceState(master, target, ['salt.minion']) |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 54 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 55 | salt.enforceState(master, target, ['linux', 'openssh', 'ntp']) |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 56 | sleep(5) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 57 | salt.enforceState(master, target, ['linux.network.host']) |
Jiri Broulik | 976bf6c | 2017-10-20 14:43:25 +0200 | [diff] [blame] | 58 | } |
| 59 | |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 60 | def installInfraKvm(master) { |
| 61 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 62 | salt.fullRefresh(master, 'I@linux:system') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 63 | |
Richard Felkl | 286f25f | 2017-07-26 14:23:55 +0200 | [diff] [blame] | 64 | salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 65 | salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp']) |
| 66 | salt.enforceState(master, 'I@salt:control', 'libvirt') |
| 67 | salt.enforceState(master, 'I@salt:control', 'salt.control') |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 68 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 69 | sleep(600) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 70 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 71 | salt.fullRefresh(master, '* and not kvm*') |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 72 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 73 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 74 | def installInfra(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 75 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 76 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 77 | // Install glusterfs |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 78 | if (salt.testTarget(master, 'I@glusterfs:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 79 | salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service') |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 80 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 81 | salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5) |
| 82 | salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status") |
Alexander Noskov | 93acac4 | 2017-06-20 17:55:55 +0200 | [diff] [blame] | 83 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 84 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 85 | // Ensure glusterfs clusters is ready |
| 86 | if (salt.testTarget(master, 'I@glusterfs:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 87 | salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client') |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 88 | } |
| 89 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 90 | // Install galera |
Richard Felkl | c0f163e | 2017-07-27 15:11:12 +0200 | [diff] [blame] | 91 | if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 92 | salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 93 | |
| 94 | // Check galera status |
| 95 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 96 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 97 | // If galera is not enabled check if we need to install mysql:server |
| 98 | } else if (salt.testTarget(master, 'I@mysql:server')){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 99 | salt.enforceState(master, 'I@mysql:server', 'mysql.server') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 100 | if (salt.testTarget(master, 'I@mysql:client')){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 101 | salt.enforceState(master, 'I@mysql:client', 'mysql.client') |
Vasyl Saienko | c1fb989 | 2017-07-13 14:54:13 +0300 | [diff] [blame] | 102 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 103 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 104 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 105 | // Install docker |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 106 | if (salt.testTarget(master, 'I@docker:host')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 107 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
Tomáš Kukrál | 0cf3ffb | 2017-09-03 10:18:18 +0200 | [diff] [blame] | 108 | salt.cmdRun(master, 'I@docker:host', 'docker ps') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 109 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 110 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 111 | // Install keepalived |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 112 | if (salt.testTarget(master, 'I@keepalived:cluster')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 113 | salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived') |
| 114 | salt.enforceState(master, 'I@keepalived:cluster', 'keepalived') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | // Install rabbitmq |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 118 | if (salt.testTarget(master, 'I@rabbitmq:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 119 | salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2) |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 120 | |
| 121 | // Check the rabbitmq status |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 122 | salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 123 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 124 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 125 | // Install haproxy |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 126 | if (salt.testTarget(master, 'I@haproxy:proxy')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 127 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 128 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 129 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
| 130 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 131 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 132 | // Install memcached |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 133 | if (salt.testTarget(master, 'I@memcached:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 134 | salt.enforceState(master, 'I@memcached:server', 'memcached') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | // Install etcd |
Tomáš Kukrál | d0cf7ec | 2017-07-13 11:29:20 +0200 | [diff] [blame] | 138 | if (salt.testTarget(master, 'I@etcd:server')) { |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 139 | salt.enforceState(master, 'I@etcd:server', 'etcd.server.service') |
vrovachev | 076e5c9 | 2017-11-13 18:56:17 +0400 | [diff] [blame] | 140 | salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health') |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
| 144 | def installOpenstackInfra(master) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 145 | def common = new com.mirantis.mk.Common() |
| 146 | common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly") |
| 147 | installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 151 | def installOpenstackControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 152 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 153 | |
| 154 | // Install horizon dashboard |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 155 | if (salt.testTarget(master, 'I@horizon:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 156 | salt.enforceState(master, 'I@horizon:server', 'horizon') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 157 | } |
| 158 | if (salt.testTarget(master, 'I@nginx:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 159 | salt.enforceState(master, 'I@nginx:server', 'salt.minion') |
| 160 | salt.enforceState(master, 'I@nginx:server', 'nginx') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 161 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 162 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 163 | // setup keystone service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 164 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 165 | salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server') |
| 166 | salt.enforceState(master, 'I@keystone:server', 'keystone.server') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 167 | // populate keystone services/tenants/roles/users |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 168 | |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 169 | // keystone:client must be called locally |
| 170 | //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| 171 | salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2']) |
| 172 | sleep(30) |
| 173 | } |
| 174 | if (salt.testTarget(master, 'I@keystone:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 175 | salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client') |
| 176 | salt.enforceState(master, 'I@keystone:client', 'keystone.client') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 177 | } |
| 178 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 179 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 180 | } |
Tomáš Kukrál | 926e633 | 2017-03-02 09:23:03 +0100 | [diff] [blame] | 181 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 182 | // Install glance |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 183 | if (salt.testTarget(master, 'I@glance:server')) { |
| 184 | //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 185 | salt.enforceState(master, 'I@glance:server and *01*', 'glance.server') |
| 186 | salt.enforceState(master, 'I@glance:server', 'glance.server') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 187 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 188 | |
Oleg Grigorov | 26c8a6c | 2017-08-17 18:54:02 +0300 | [diff] [blame] | 189 | // Check glance service |
| 190 | if (salt.testTarget(master, 'I@glance:server')){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 191 | salt.cmdRun(master, 'I@keystone:server','. /root/keystonerc; glance image-list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 192 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 193 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 194 | // Create glance resources |
| 195 | if (salt.testTarget(master, 'I@glance:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 196 | salt.enforceState(master, 'I@glance:client', 'glance.client') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 197 | } |
| 198 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 199 | // Install and check nova service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 200 | if (salt.testTarget(master, 'I@nova:controller')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 201 | // run on first node first |
| 202 | salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller') |
| 203 | salt.enforceState(master, 'I@nova:controller', 'nova.controller') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 204 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 205 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonerc; nova service-list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 206 | } |
| 207 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 208 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 209 | // Create nova resources |
| 210 | if (salt.testTarget(master, 'I@nova:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 211 | salt.enforceState(master, 'I@nova:client', 'nova.client') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 212 | } |
| 213 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 214 | // Install and check cinder service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 215 | if (salt.testTarget(master, 'I@cinder:controller')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 216 | // run on first node first |
| 217 | salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder') |
| 218 | salt.enforceState(master, 'I@cinder:controller', 'cinder') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 219 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 220 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonerc; cinder list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 221 | } |
| 222 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 223 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 224 | // Install neutron service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 225 | if (salt.testTarget(master, 'I@neutron:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 226 | // run on first node first |
| 227 | salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server') |
| 228 | salt.enforceState(master, 'I@neutron:server', 'neutron.server') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 229 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 230 | salt.cmdRun(master, 'I@keystone:server','. /root/keystonerc; neutron agent-list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 231 | } |
| 232 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 233 | |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 234 | // Create neutron resources |
| 235 | if (salt.testTarget(master, 'I@neutron:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 236 | salt.enforceState(master, 'I@neutron:client', 'neutron.client') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 237 | } |
| 238 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 239 | // Install heat service |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 240 | if (salt.testTarget(master, 'I@heat:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 241 | // run on first node first |
| 242 | salt.enforceState(master, 'I@heat:server and *01*', 'heat') |
| 243 | salt.enforceState(master, 'I@heat:server', 'heat') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 244 | if (salt.testTarget(master, 'I@keystone:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 245 | salt.cmdRun(master, 'I@keystone:server', '. /root/keystonerc; heat resource-type-list') |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 246 | } |
| 247 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 248 | |
| 249 | // Restart nova api |
Vasyl Saienko | 962e0b5 | 2017-07-11 10:49:19 +0300 | [diff] [blame] | 250 | if (salt.testTarget(master, 'I@nova:controller')) { |
| 251 | salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api']) |
| 252 | } |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 253 | |
| 254 | // Install ironic service |
| 255 | if (salt.testTarget(master, 'I@ironic:api')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 256 | salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api') |
| 257 | salt.enforceState(master, 'I@ironic:api', 'ironic.api') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 258 | } |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 259 | |
| 260 | // Install designate service |
| 261 | if (salt.testTarget(master, 'I@designate:server:enabled')) { |
| 262 | if (salt.testTarget(master, 'I@designate:server:backend:bind9')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 263 | salt.enforceState(master, 'I@bind:server', 'bind.server') |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 264 | } |
| 265 | if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 266 | salt.enforceState(master, 'I@powerdns:server', 'powerdns.server') |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 267 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 268 | salt.enforceState(master, 'I@designate:server and *01*', 'designate.server') |
| 269 | salt.enforceState(master, 'I@designate:server', 'designate.server') |
Andrey Shestakov | 82c0b89 | 2017-07-24 18:46:21 +0300 | [diff] [blame] | 270 | } |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 271 | |
| 272 | // Install octavia api service |
| 273 | if (salt.testTarget(master, 'I@octavia:api')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 274 | salt.enforceState(master, 'I@octavia:api', 'octavia') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 275 | } |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 276 | |
Oleg Iurchenko | d0898c9 | 2017-12-14 14:28:44 +0200 | [diff] [blame] | 277 | // Install DogTag server service |
| 278 | if (salt.testTarget(master, 'I@dogtag:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 279 | salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server') |
| 280 | salt.enforceState(master, 'I@dogtag:server', 'dogtag.server') |
Oleg Iurchenko | d0898c9 | 2017-12-14 14:28:44 +0200 | [diff] [blame] | 281 | } |
| 282 | |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 283 | // Install barbican server service |
| 284 | if (salt.testTarget(master, 'I@barbican:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 285 | salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server') |
| 286 | salt.enforceState(master, 'I@barbican:server', 'barbican.server') |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 287 | } |
| 288 | // Install barbican client |
| 289 | if (salt.testTarget(master, 'I@barbican:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 290 | salt.enforceState(master, 'I@barbican:client', 'barbican.client') |
Marek Celoud | c9dd50f | 2017-08-28 13:54:40 +0200 | [diff] [blame] | 291 | } |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 292 | |
| 293 | // Install ceilometer server |
| 294 | if (salt.testTarget(master, 'I@ceilometer:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 295 | salt.enforceState(master, 'I@ceilometer:server', 'ceilometer') |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | // Install aodh server |
| 299 | if (salt.testTarget(master, 'I@aodh:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 300 | salt.enforceState(master, 'I@aodh:server', 'aodh') |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 301 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 305 | def installIronicConductor(master){ |
| 306 | def salt = new com.mirantis.mk.Salt() |
| 307 | |
| 308 | if (salt.testTarget(master, 'I@ironic:conductor')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 309 | salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor') |
| 310 | salt.enforceState(master, 'I@ironic:conductor', 'apache') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 311 | } |
| 312 | if (salt.testTarget(master, 'I@tftpd_hpa:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 313 | salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | if (salt.testTarget(master, 'I@nova:compute')) { |
| 317 | salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute']) |
| 318 | } |
| 319 | |
| 320 | if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 321 | salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 322 | } |
| 323 | if (salt.testTarget(master, 'I@ironic:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 324 | salt.enforceState(master, 'I@ironic:client', 'ironic.client') |
Vasyl Saienko | a7c10c0 | 2017-07-13 10:43:43 +0300 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | |
| 328 | |
| 329 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 330 | def installOpenstackNetwork(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 331 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 332 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 333 | salt.enforceHighstate(master, 'I@neutron:gateway') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 334 | |
| 335 | // install octavia manager services |
| 336 | if (salt.testTarget(master, 'I@octavia:manager')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 337 | salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*']) |
| 338 | salt.enforceState(master, 'I@octavia:manager', 'octavia') |
| 339 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca') |
| 340 | salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert') |
Elena Ezhova | 8d53bff | 2017-08-01 17:43:30 +0400 | [diff] [blame] | 341 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | |
| 345 | def installOpenstackCompute(master) { |
| 346 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 347 | // Configure compute nodes |
| 348 | retry(2) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 349 | salt.enforceHighstateWithExclude(master, 'I@nova:compute', 'opencontrail.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
| 353 | |
| 354 | def installContrailNetwork(master) { |
Martin Polreich | fc9854c | 2017-06-30 11:17:36 +0200 | [diff] [blame] | 355 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 356 | def salt = new com.mirantis.mk.Salt() |
| 357 | |
| 358 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 359 | // Install opencontrail database services |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 360 | salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database') |
| 361 | salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 362 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 363 | // Install opencontrail control services |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 364 | salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client") |
| 365 | salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client") |
| 366 | salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client") |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 367 | |
Marek Celoud | 443fb64 | 2017-11-22 15:07:12 +0100 | [diff] [blame] | 368 | if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 369 | salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client') |
Marek Celoud | 443fb64 | 2017-11-22 15:07:12 +0100 | [diff] [blame] | 370 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 374 | def installContrailCompute(master) { |
Tomáš Kukrál | 104a07a | 2017-07-13 12:19:11 +0200 | [diff] [blame] | 375 | def salt = new com.mirantis.mk.Salt() |
vrovachev | 32f7f54 | 2017-08-25 16:17:25 +0400 | [diff] [blame] | 376 | def common = new com.mirantis.mk.Common() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 377 | // Configure compute nodes |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 378 | // Provision opencontrail control services |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 379 | salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 380 | // Provision opencontrail virtual routers |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 381 | |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 382 | // Generate script /usr/lib/contrail/if-vhost0 for up vhost0 |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 383 | salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client") |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 384 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 385 | salt.cmdRun(master, 'I@nova:compute', 'exec 0>&-; exec 1>&-; exec 2>&-; nohup bash -c "ip link | grep vhost && echo no_reboot || sleep 5 && reboot & "') |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 386 | |
| 387 | if (salt.testTarget(master, 'I@opencontrail:compute')) { |
| 388 | sleep(300) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 389 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client') |
| 390 | salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail') |
vrovachev | 4ff7730 | 2017-08-09 20:39:57 +0400 | [diff] [blame] | 391 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 395 | def installKubernetesInfra(master) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 396 | def common = new com.mirantis.mk.Common() |
| 397 | common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly") |
| 398 | installInfra(master) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | |
Tomáš Kukrál | c1a1bbc | 2017-04-28 21:16:25 +0200 | [diff] [blame] | 402 | def installKubernetesControl(master) { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 403 | def salt = new com.mirantis.mk.Salt() |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 404 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 405 | // Install Kubernetes pool and Calico |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 406 | salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons') |
| 407 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 408 | |
Marek Celoud | 029391c | 2017-11-14 10:06:18 +0100 | [diff] [blame] | 409 | if (salt.testTarget(master, 'I@etcd:server:setup')) { |
| 410 | // Setup etcd server |
| 411 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup') |
| 412 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 413 | |
| 414 | // Run k8s without master.setup |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 415 | salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup") |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 416 | |
| 417 | // Run k8s master setup |
Tomáš Kukrál | b05cf00 | 2017-05-02 11:05:43 +0200 | [diff] [blame] | 418 | salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup') |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 419 | |
| 420 | // Restart kubelet |
| 421 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
| 422 | } |
| 423 | |
| 424 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 425 | def installKubernetesCompute(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 426 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 427 | salt.fullRefresh(master, "*") |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 428 | |
| 429 | // Bootstrap all nodes |
| 430 | salt.enforceState(master, 'I@kubernetes:pool', 'linux') |
| 431 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion') |
| 432 | salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp']) |
| 433 | |
| 434 | // Create and distribute SSL certificates for services using salt state |
| 435 | salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert') |
| 436 | |
| 437 | // Install docker |
| 438 | salt.enforceState(master, 'I@docker:host', 'docker.host') |
| 439 | |
| 440 | // Install Kubernetes and Calico |
| 441 | salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
| 442 | |
Yuriy Taraday | ab564d7 | 2017-10-11 15:14:35 +0400 | [diff] [blame] | 443 | // Install Tiller and all configured releases |
| 444 | if (salt.testTarget(master, 'I@helm:client')) { |
| 445 | salt.enforceState(master, 'I@helm:client', 'helm') |
| 446 | } |
Tomáš Kukrál | e7e2896 | 2017-06-06 11:11:16 +0200 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 450 | def installDockerSwarm(master) { |
| 451 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 452 | |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 453 | //Install and Configure Docker |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 454 | salt.enforceState(master, 'I@docker:swarm', 'docker.host') |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 455 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm') |
| 456 | salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains') |
| 457 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update') |
| 458 | salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 459 | sleep(5) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 460 | salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm') |
| 461 | salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm') |
| 462 | salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 463 | } |
| 464 | |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 465 | |
| 466 | def installCicd(master) { |
| 467 | def salt = new com.mirantis.mk.Salt() |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 468 | salt.fullRefresh(master, 'I@jenkins:client or I@gerrit:client') |
Richard Felkl | 9d2cd92 | 2017-11-03 11:49:32 +0100 | [diff] [blame] | 469 | |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 470 | if (salt.testTarget(master, 'I@aptly:publisher')) { |
| 471 | salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2) |
| 472 | } |
| 473 | |
Richard Felkl | 6de1676 | 2017-11-20 11:42:28 +0100 | [diff] [blame] | 474 | salt.enforceState(master, 'I@docker:swarm:role:master and I@jenkins:client', 'docker.client', true, true, null, false, -1, 2) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 475 | sleep(500) |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 476 | |
| 477 | if (salt.testTarget(master, 'I@aptly:server')) { |
| 478 | salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2) |
| 479 | } |
| 480 | |
| 481 | if (salt.testTarget(master, 'I@openldap:client')) { |
| 482 | salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2) |
| 483 | } |
Richard Felkl | b6fdec9 | 2017-09-26 10:52:36 +0200 | [diff] [blame] | 484 | |
| 485 | if (salt.testTarget(master, 'I@python:environment')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 486 | salt.enforceState(master, 'I@python:environment', 'python') |
Richard Felkl | b6fdec9 | 2017-09-26 10:52:36 +0200 | [diff] [blame] | 487 | } |
Richard Felkl | c1aba9b | 2018-01-02 09:25:20 +0100 | [diff] [blame] | 488 | |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 489 | withEnv(['ASK_ON_ERROR=false']){ |
| 490 | retry(2){ |
| 491 | try{ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 492 | salt.enforceState(master, 'I@gerrit:client', 'gerrit') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 493 | }catch(e){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 494 | salt.fullRefresh(master, 'I@gerrit:client') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 495 | throw e //rethrow for retry handler |
| 496 | } |
| 497 | } |
| 498 | retry(2){ |
| 499 | try{ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 500 | salt.enforceState(master, 'I@jenkins:client', 'jenkins') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 501 | }catch(e){ |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 502 | salt.fullRefresh(master, 'I@jenkins:client') |
Richard Felkl | 6e208fc | 2017-12-08 10:18:44 +0100 | [diff] [blame] | 503 | throw e //rethrow for retry handler |
| 504 | } |
| 505 | } |
| 506 | } |
Jiri Broulik | b9a0c59 | 2017-09-05 16:41:48 +0200 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 510 | def installStacklight(master) { |
| 511 | def common = new com.mirantis.mk.Common() |
| 512 | def salt = new com.mirantis.mk.Salt() |
| 513 | |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 514 | // Install core services for K8S environments: |
| 515 | // HAProxy, Nginx and lusterFS clients |
| 516 | // In case of OpenStack, those are already installed |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 517 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 518 | salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
| 519 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 520 | |
| 521 | if (salt.testTarget(master, 'I@nginx:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 522 | salt.enforceState(master, 'I@nginx:server', 'nginx') |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | if (salt.testTarget(master, 'I@glusterfs:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 526 | salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client') |
Simon Pasquier | ef4122c | 2017-08-25 15:52:07 +0200 | [diff] [blame] | 527 | } |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 528 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 529 | |
| 530 | // Launch containers |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 531 | salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client') |
| 532 | salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps') |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 533 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 534 | //Install Telegraf |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 535 | salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 536 | |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 537 | // Install Prometheus exporters |
| 538 | if (salt.testTarget(master, 'I@prometheus:exporters')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 539 | salt.enforceState(master, 'I@prometheus:exporters', 'prometheus') |
Dmitry Kalashnik | ebc1e1e | 2017-07-13 14:20:08 +0400 | [diff] [blame] | 540 | } |
| 541 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 542 | //Install Elasticsearch and Kibana |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 543 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server') |
| 544 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server') |
| 545 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server') |
| 546 | salt.enforceState(master, 'I@kibana:server', 'kibana.server') |
| 547 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client') |
| 548 | salt.enforceState(master, 'I@kibana:client', 'kibana.client') |
| 549 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb') |
| 550 | salt.enforceState(master, 'I@influxdb:server', 'influxdb') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 551 | |
Simon Pasquier | 6301ddd | 2017-09-05 11:56:58 +0200 | [diff] [blame] | 552 | salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector') |
| 553 | |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 554 | // Install heka ceilometer collector |
| 555 | if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 556 | salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector') |
Ondrej Smola | 5908ae6 | 2018-01-08 13:42:08 +0100 | [diff] [blame] | 557 | salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true) |
| 558 | } |
| 559 | |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 560 | // Install galera |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 561 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 562 | salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2) |
| 563 | salt.enforceState(master, 'I@galera:slave', 'galera') |
Martin Polreich | 406f646 | 2017-07-11 11:33:42 +0000 | [diff] [blame] | 564 | |
Martin Polreich | 792f266 | 2017-07-11 13:36:32 +0200 | [diff] [blame] | 565 | // Check galera status |
| 566 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 567 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
| 568 | } |
Martin Polreich | 470925a | 2017-07-06 17:12:59 +0200 | [diff] [blame] | 569 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 570 | //Collect Grains |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 571 | salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains') |
| 572 | salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules') |
| 573 | salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 574 | sleep(5) |
| 575 | |
| 576 | //Configure services in Docker Swarm |
Martin Polreich | 8017f45 | 2017-08-21 16:01:42 +0200 | [diff] [blame] | 577 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 578 | salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus', true, false) |
| 579 | } else { |
| 580 | salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', ['prometheus', 'heka.remote_collector'], true, false) |
Martin Polreich | 8017f45 | 2017-08-21 16:01:42 +0200 | [diff] [blame] | 581 | } |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 582 | |
| 583 | //Configure Grafana |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 584 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 585 | common.prettyPrint(pillar) |
Martin Polreich | 595baef | 2017-07-04 16:11:04 +0200 | [diff] [blame] | 586 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 587 | def stacklight_vip |
| 588 | if(!pillar['return'].isEmpty()) { |
| 589 | stacklight_vip = pillar['return'][0].values()[0] |
| 590 | } else { |
| 591 | common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved') |
| 592 | } |
vrovachev | 1c4770b | 2017-07-05 13:25:21 +0400 | [diff] [blame] | 593 | |
Martin Polreich | 305e222 | 2017-07-06 11:33:00 +0200 | [diff] [blame] | 594 | common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start") |
Martin Polreich | bd7ad22 | 2017-07-06 12:53:51 +0200 | [diff] [blame] | 595 | sleep(120) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 596 | salt.enforceState(master, 'I@grafana:client', 'grafana.client') |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | def installStacklightv1Control(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 600 | def salt = new com.mirantis.mk.Salt() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 601 | |
| 602 | // infra install |
| 603 | // Install the StackLight backends |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 604 | salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server') |
| 605 | salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 606 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 607 | salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb') |
| 608 | salt.enforceState(master, 'I@influxdb:server', 'influxdb') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 609 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 610 | salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server') |
| 611 | salt.enforceState(master, 'I@kibana:server', 'kibana.server') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 612 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 613 | salt.enforceState(master, '*01* and I@grafana:server','grafana.server') |
| 614 | salt.enforceState(master, 'I@grafana:server','grafana.server') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 615 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 616 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 617 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
| 618 | |
| 619 | switch (alarming_service) { |
| 620 | case 'sensu': |
| 621 | // Update Sensu |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 622 | salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq') |
| 623 | salt.enforceState(master, 'I@redis:cluster:role:master', 'redis') |
| 624 | salt.enforceState(master, 'I@redis:server', 'redis') |
| 625 | salt.enforceState(master, 'I@sensu:server', 'sensu') |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 626 | default: |
| 627 | // Update Nagios |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 628 | salt.enforceState(master, 'I@nagios:server', 'nagios.server') |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 629 | // Stop the Nagios service because the package starts it by default and it will |
| 630 | // started later only on the node holding the VIP address |
| 631 | salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true) |
| 632 | } |
| 633 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 634 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service') |
| 635 | salt.enforceState(master, 'I@kibana:client', 'kibana.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 636 | |
| 637 | sleep(10) |
| 638 | } |
| 639 | |
Martin Polreich | 8663a34 | 2017-06-30 17:33:08 +0200 | [diff] [blame] | 640 | def installStacklightv1Client(master) { |
Tomáš Kukrál | a53b535 | 2017-05-04 11:45:53 +0200 | [diff] [blame] | 641 | def salt = new com.mirantis.mk.Salt() |
| 642 | def common = new com.mirantis.mk.Common() |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 643 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 644 | salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 645 | // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 646 | salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 647 | // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
| 648 | |
| 649 | // Install collectd, heka and sensu services on the nodes, this will also |
| 650 | // generate the metadata that goes into the grains and eventually into Salt Mine |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 651 | salt.enforceState(master, '*', 'collectd') |
| 652 | salt.enforceState(master, '*', 'salt.minion') |
| 653 | salt.enforceState(master, '*', 'heka') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 654 | |
| 655 | // Gather the Grafana metadata as grains |
| 656 | salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true) |
| 657 | |
| 658 | // Update Salt Mine |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 659 | salt.enforceState(master, '*', 'salt.minion.grains') |
| 660 | salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules') |
| 661 | salt.runSaltProcessStep(master, '*', 'mine.update') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 662 | |
| 663 | sleep(5) |
| 664 | |
| 665 | // Update Heka |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 666 | salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 667 | |
| 668 | // Update collectd |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 669 | salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 670 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 671 | def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| 672 | def alarming_service = alarming_service_pillar['return'][0].values()[0] |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 673 | |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 674 | switch (alarming_service) { |
| 675 | case 'sensu': |
| 676 | // Update Sensu |
| 677 | // TODO for stacklight team, should be fixed in model |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 678 | salt.enforceState(master, 'I@sensu:client', 'sensu') |
Kalynovskyi | 3e37011 | 2017-06-26 12:48:23 +0300 | [diff] [blame] | 679 | default: |
| 680 | break |
| 681 | // Default is nagios, and was enforced in installStacklightControl() |
| 682 | } |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 683 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 684 | salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client') |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 685 | // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| 686 | |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 687 | // Finalize the configuration of Grafana (add the dashboards...) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 688 | salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client') |
| 689 | salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client') |
| 690 | salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client') |
Marek Celoud | d200cad | 2017-06-07 10:34:46 +0200 | [diff] [blame] | 691 | // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
| 692 | |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 693 | // Get the StackLight monitoring VIP addres |
| 694 | //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| 695 | //vip=${vip:=172.16.10.253} |
| 696 | def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
Jakub Josef | bceaa32 | 2017-06-13 18:28:27 +0200 | [diff] [blame] | 697 | common.prettyPrint(pillar) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 698 | def stacklight_vip = pillar['return'][0].values()[0] |
| 699 | |
| 700 | if (stacklight_vip) { |
| 701 | // (re)Start manually the services that are bound to the monitoring VIP |
| 702 | common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 703 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd']) |
| 704 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector']) |
| 705 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator']) |
| 706 | salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3']) |
Ales Komarek | ef2bab6 | 2017-04-26 11:48:28 +0200 | [diff] [blame] | 707 | } else { |
| 708 | throw new Exception("Missing stacklight_vip") |
| 709 | } |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 710 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 711 | |
| 712 | |
| 713 | // |
| 714 | // Ceph |
| 715 | // |
| 716 | |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 717 | def installCephMon(master, target='I@ceph:mon') { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 718 | def salt = new com.mirantis.mk.Salt() |
| 719 | |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 720 | salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains') |
Jiri Broulik | bfc234f | 2017-10-17 15:45:38 +0200 | [diff] [blame] | 721 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 722 | // generate keyrings |
| 723 | if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 724 | salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon') |
| 725 | salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains') |
| 726 | salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update') |
Jiri Broulik | 3c75a6d | 2017-10-06 18:44:37 +0200 | [diff] [blame] | 727 | sleep(5) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 728 | } |
Ondrej Smola | fd5c235 | 2017-08-11 14:25:39 +0200 | [diff] [blame] | 729 | // install Ceph Mons |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 730 | salt.enforceState(master, target, 'ceph.mon') |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 731 | if (salt.testTarget(master, 'I@ceph:mgr')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 732 | salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr') |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 733 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 734 | } |
| 735 | |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 736 | def installCephOsd(master, target='I@ceph:osd', setup=true) { |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 737 | def salt = new com.mirantis.mk.Salt() |
| 738 | |
| 739 | // install Ceph OSDs |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 740 | salt.enforceState(master, target, 'ceph.osd') |
| 741 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains') |
| 742 | salt.enforceState(master, target, 'ceph.osd.custom') |
| 743 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains') |
| 744 | salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update') |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 745 | |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 746 | // setup pools, keyrings and maybe crush |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 747 | if (salt.testTarget(master, 'I@ceph:setup') && setup) { |
Jiri Broulik | 07f8de7 | 2017-10-09 14:12:17 +0200 | [diff] [blame] | 748 | sleep(5) |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 749 | salt.enforceState(master, 'I@ceph:setup', 'ceph.setup') |
Tomáš Kukrál | ed27a47 | 2017-08-29 10:26:25 +0200 | [diff] [blame] | 750 | } |
Tomáš Kukrál | 64f8e1c | 2017-08-11 10:32:20 +0200 | [diff] [blame] | 751 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 752 | |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 753 | def installCephClient(master) { |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 754 | def salt = new com.mirantis.mk.Salt() |
| 755 | |
| 756 | // install Ceph Radosgw |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 757 | if (salt.testTarget(master, 'I@ceph:radosgw')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 758 | salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains') |
| 759 | salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw') |
Alexander Noskov | 229035f | 2017-12-06 00:10:20 +0400 | [diff] [blame] | 760 | } |
| 761 | // setup Keystone service and endpoints for swift or / and S3 |
| 762 | if (salt.testTarget(master, 'I@keystone:client')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 763 | salt.enforceState(master, 'I@keystone:client', 'keystone.client') |
Tomáš Kukrál | 5836e3d | 2017-08-25 18:20:55 +0200 | [diff] [blame] | 764 | } |
Tomáš Kukrál | 1e5b219 | 2017-08-15 16:58:18 +0200 | [diff] [blame] | 765 | } |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 766 | |
| 767 | def connectCeph(master) { |
| 768 | def salt = new com.mirantis.mk.Salt() |
| 769 | |
| 770 | // connect Ceph to the env |
| 771 | if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 772 | salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance']) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 773 | salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api', 'glance-glare', 'glance-registry']) |
| 774 | } |
| 775 | if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 776 | salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder']) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 777 | } |
| 778 | if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 779 | salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring']) |
| 780 | salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains') |
| 781 | salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova']) |
Jiri Broulik | e57a024 | 2017-10-06 13:38:47 +0200 | [diff] [blame] | 782 | } |
| 783 | } |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 784 | |
| 785 | def installOssInfra(master) { |
| 786 | def common = new com.mirantis.mk.Common() |
| 787 | def salt = new com.mirantis.mk.Salt() |
| 788 | |
Mikhail Ivanov | 788996c | 2017-12-15 14:28:57 +0400 | [diff] [blame] | 789 | if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) { |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 790 | def orchestrate = new com.mirantis.mk.Orchestrate() |
| 791 | orchestrate.installInfra(master) |
| 792 | } |
| 793 | |
| 794 | if (salt.testTarget(master, 'I@devops_portal:config')) { |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 795 | salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config') |
| 796 | salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh']) |
| 797 | salt.enforceState(master, 'I@rundeck:server', 'rundeck.server') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | |
| 801 | def installOss(master) { |
| 802 | def common = new com.mirantis.mk.Common() |
| 803 | def salt = new com.mirantis.mk.Salt() |
| 804 | |
| 805 | //Get oss VIP address |
| 806 | def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address') |
| 807 | common.prettyPrint(pillar) |
| 808 | |
| 809 | def oss_vip |
| 810 | if(!pillar['return'].isEmpty()) { |
| 811 | oss_vip = pillar['return'][0].values()[0] |
| 812 | } else { |
| 813 | common.errorMsg('[ERROR] Oss VIP address could not be retrieved') |
| 814 | } |
| 815 | |
| 816 | // Postgres client - initialize OSS services databases |
| 817 | timeout(120){ |
| 818 | common.infoMsg("Waiting for postgresql database to come up..") |
| 819 | salt.cmdRun(master, 'I@postgresql:client', 'while true; do if docker service logs postgresql_postgresql-db | grep "ready to accept"; then break; else sleep 5; fi; done') |
| 820 | } |
| 821 | // XXX: first run usually fails on some inserts, but we need to create databases at first |
| 822 | salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false) |
| 823 | |
| 824 | // Setup postgres database with integration between |
| 825 | // Pushkin notification service and Security Monkey security audit service |
| 826 | timeout(10) { |
| 827 | common.infoMsg("Waiting for Pushkin to come up..") |
| 828 | salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done") |
| 829 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 830 | salt.enforceState(master, 'I@postgresql:client', 'postgresql.client') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 831 | |
| 832 | // Rundeck |
| 833 | timeout(10) { |
| 834 | common.infoMsg("Waiting for Rundeck to come up..") |
| 835 | salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done") |
| 836 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 837 | salt.enforceState(master, 'I@rundeck:client', 'rundeck.client') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 838 | |
| 839 | // Elasticsearch |
Mikhail Ivanov | fcd55d6 | 2017-12-19 16:51:35 +0400 | [diff] [blame] | 840 | pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host') |
| 841 | def elasticsearch_vip |
| 842 | if(!pillar['return'].isEmpty()) { |
| 843 | elasticsearch_vip = pillar['return'][0].values()[0] |
| 844 | } else { |
| 845 | common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| 846 | } |
| 847 | |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 848 | timeout(10) { |
| 849 | common.infoMsg('Waiting for Elasticsearch to come up..') |
Mikhail Ivanov | fcd55d6 | 2017-12-19 16:51:35 +0400 | [diff] [blame] | 850 | salt.cmdRun(master, 'I@elasticsearch:client', "while true; do curl -sf ${elasticsearch_vip}:9200 >/dev/null && break; done") |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 851 | } |
Jakub Josef | 432e9d9 | 2018-02-06 18:28:37 +0100 | [diff] [blame^] | 852 | salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client') |
Mikhail Ivanov | 5312d1f | 2017-12-06 17:36:36 +0400 | [diff] [blame] | 853 | } |