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