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() |
| 9 | salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['salt-key']) |
| 10 | salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version') |
| 11 | salt.runSaltProcessStep(master, 'I@salt:master', 'cmd.run', ['reclass-salt --top']) |
| 12 | salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory') |
| 13 | salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top') |
| 14 | } |
| 15 | |
| 16 | |
| 17 | def installFoundationInfra(master) { |
| 18 | def salt = new com.mirantis.mk.Salt() |
| 19 | salt.runSaltProcessStep(master, 'I@salt:master', 'state.sls', ['salt.master,reclass']) |
| 20 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar') |
| 21 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all') |
| 22 | salt.runSaltProcessStep(master, 'I@linux:system', 'state.sls', ['linux,openssh,salt.minion,ntp']) |
| 23 | } |
| 24 | |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 25 | def installInfraKvm(master) { |
| 26 | def salt = new com.mirantis.mk.Salt() |
| 27 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.refresh_pillar') |
| 28 | salt.runSaltProcessStep(master, 'I@linux:system', 'saltutil.sync_all') |
| 29 | |
| 30 | salt.runSaltProcessStep(master, 'I@salt:control', 'state.sls', ['salt.minion,linux.system,linux.network,ntp']) |
| 31 | salt.runSaltProcessStep(master, 'I@salt:control', 'state.sls', ['libvirt']) |
| 32 | salt.runSaltProcessStep(master, 'I@salt:control', 'state.sls', ['salt.control']) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 33 | |
Tomáš Kukrál | adf8395 | 2017-03-01 18:10:50 +0100 | [diff] [blame^] | 34 | sleep(300) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 35 | |
Tomáš Kukrál | adf8395 | 2017-03-01 18:10:50 +0100 | [diff] [blame^] | 36 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.refresh_pillar') |
| 37 | salt.runSaltProcessStep(master, '* and not kvm*', 'saltutil.sync_all') |
| 38 | salt.runSaltProcessStep(master, '* and not kvm*', 'state.sls', ['linux,openssh,salt.minion,ntp']) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 39 | |
Tomáš Kukrál | 8d2be5a | 2017-02-28 11:22:29 +0100 | [diff] [blame] | 40 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 41 | |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 42 | def installOpenstackMkInfra(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 43 | def salt = new com.mirantis.mk.Salt() |
| 44 | // Install keepaliveds |
| 45 | //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1) |
| 46 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keepalived']) |
| 47 | salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived']) |
| 48 | // Check the keepalived VIPs |
| 49 | salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2']) |
| 50 | // Install glusterfs |
| 51 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service']) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 52 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 53 | //runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 54 | if (physical.equals("false")) { |
| 55 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glusterfs.server.setup']) |
| 56 | salt.runSaltProcessStep(master, 'ctl02*', 'state.sls', ['glusterfs.server.setup']) |
| 57 | salt.runSaltProcessStep(master, 'ctl03*', 'state.sls', ['glusterfs.server.setup']) |
| 58 | } else { |
| 59 | salt.runSaltProcessStep(master, 'kvm01*', 'state.sls', ['glusterfs.server.setup']) |
| 60 | salt.runSaltProcessStep(master, 'kvm02*', 'state.sls', ['glusterfs.server.setup']) |
| 61 | salt.runSaltProcessStep(master, 'kvm03*', 'state.sls', ['glusterfs.server.setup']) |
| 62 | } |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 63 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status']) |
| 64 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status']) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 65 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 66 | // Install rabbitmq |
| 67 | salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'state.sls', ['rabbitmq']) |
| 68 | // Check the rabbitmq status |
| 69 | salt.runSaltProcessStep(master, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status']) |
| 70 | // Install galera |
| 71 | salt.runSaltProcessStep(master, 'I@galera:master', 'state.sls', ['galera']) |
| 72 | salt.runSaltProcessStep(master, 'I@galera:slave', 'state.sls', ['galera']) |
| 73 | // Check galera status |
| 74 | salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| 75 | salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
| 76 | // Install haproxy |
| 77 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'state.sls', ['haproxy']) |
| 78 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 79 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
| 80 | // Install memcached |
| 81 | salt.runSaltProcessStep(master, 'I@memcached:server', 'state.sls', ['memcached']) |
| 82 | } |
| 83 | |
| 84 | |
| 85 | def installOpenstackMkControl(master) { |
| 86 | def salt = new com.mirantis.mk.Salt() |
| 87 | // setup keystone service |
| 88 | //runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server'], 1) |
| 89 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keystone.server']) |
| 90 | salt.runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server']) |
| 91 | // populate keystone services/tenants/roles/users |
| 92 | salt.runSaltProcessStep(master, 'I@keystone:client', 'state.sls', ['keystone.client']) |
| 93 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list']) |
| 94 | // Install glance and ensure glusterfs clusters |
| 95 | //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
| 96 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glance.server']) |
| 97 | salt.runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server']) |
| 98 | salt.runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glusterfs.client']) |
| 99 | // Update fernet tokens before doing request on keystone server |
| 100 | salt.runSaltProcessStep(master, 'I@keystone:server', 'state.sls', ['keystone.server']) |
| 101 | // Check glance service |
| 102 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list']) |
| 103 | // Install and check nova service |
| 104 | //runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova'], 1) |
| 105 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['nova']) |
| 106 | salt.runSaltProcessStep(master, 'I@nova:controller', 'state.sls', ['nova']) |
| 107 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list']) |
| 108 | // Install and check cinder service |
| 109 | //runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder'], 1) |
| 110 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['cinder']) |
| 111 | salt.runSaltProcessStep(master, 'I@cinder:controller', 'state.sls', ['cinder']) |
| 112 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list']) |
| 113 | // Install neutron service |
| 114 | //runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron'], 1) |
| 115 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['neutron']) |
| 116 | salt.runSaltProcessStep(master, 'I@neutron:server', 'state.sls', ['neutron']) |
| 117 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list']) |
| 118 | // Install heat service |
| 119 | //runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat'], 1) |
| 120 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['heat']) |
| 121 | salt.runSaltProcessStep(master, 'I@heat:server', 'state.sls', ['heat']) |
| 122 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list']) |
| 123 | // Install horizon dashboard |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 124 | salt.runSaltProcessStep(master, 'I@horizon:server', 'state.sls', ['horizon']) |
| 125 | salt.runSaltProcessStep(master, 'I@nginx:server', 'state.sls', ['nginx']) |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 129 | def installOpenstackMkNetwork(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 130 | def salt = new com.mirantis.mk.Salt() |
| 131 | // Install opencontrail database services |
| 132 | //runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1) |
| 133 | salt.runSaltProcessStep(master, 'ntw01*', 'state.sls', ['opencontrail.database']) |
| 134 | salt.runSaltProcessStep(master, 'I@opencontrail:database', 'state.sls', ['opencontrail.database']) |
| 135 | // Install opencontrail control services |
| 136 | //runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1) |
| 137 | salt.runSaltProcessStep(master, 'ntw01*', 'state.sls', ['opencontrail']) |
| 138 | salt.runSaltProcessStep(master, 'I@opencontrail:control', 'state.sls', ['opencontrail']) |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 139 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 140 | // Provision opencontrail control services |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 141 | if (physical.equals("false")) { |
| 142 | salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl01 --host_ip 172.16.10.101 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add']) |
| 143 | salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl02 --host_ip 172.16.10.102 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add']) |
| 144 | salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl03 --host_ip 172.16.10.103 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add']) |
| 145 | } |
| 146 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 147 | // Test opencontrail |
| 148 | salt.runSaltProcessStep(master, 'I@opencontrail:control', 'cmd.run', ['contrail-status']) |
| 149 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list']) |
| 150 | salt.runSaltProcessStep(master, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list']) |
| 151 | } |
| 152 | |
| 153 | |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 154 | def installOpenstackMkCompute(master, physical = "false") { |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 155 | def salt = new com.mirantis.mk.Salt() |
| 156 | // Configure compute nodes |
| 157 | salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply') |
| 158 | salt.runSaltProcessStep(master, 'I@nova:compute', 'state.apply') |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 159 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 160 | // Provision opencontrail virtual routers |
Tomáš Kukrál | b8e9711 | 2017-03-01 16:03:16 +0100 | [diff] [blame] | 161 | if (physical.equals("false")) { |
| 162 | salt.runSaltProcessStep(master, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_vrouter.py --host_name cmp01 --host_ip 172.16.10.105 --api_server_ip 172.16.10.254 --oper add --admin_user admin --admin_password workshop --admin_tenant_name admin']) |
| 163 | } |
| 164 | |
Jakub Josef | 79ecec3 | 2017-02-17 14:36:28 +0100 | [diff] [blame] | 165 | salt.runSaltProcessStep(master, 'I@nova:compute', 'system.reboot') |
| 166 | } |
| 167 | |
| 168 | |
| 169 | def installOpenstackMcpInfra(master) { |
| 170 | def salt = new com.mirantis.mk.Salt() |
| 171 | // Comment nameserver |
| 172 | salt.runSaltProcessStep(master, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"]) |
| 173 | // Install glusterfs |
| 174 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service']) |
| 175 | // Install keepalived |
| 176 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['keepalived']) |
| 177 | salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived']) |
| 178 | // Check the keepalived VIPs |
| 179 | salt.runSaltProcessStep(master, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2']) |
| 180 | // Setup glusterfs |
| 181 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['glusterfs.server.setup']) |
| 182 | salt.runSaltProcessStep(master, 'ctl02*', 'state.sls', ['glusterfs.server.setup']) |
| 183 | salt.runSaltProcessStep(master, 'ctl03*', 'state.sls', ['glusterfs.server.setup']) |
| 184 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster peer status']) |
| 185 | salt.runSaltProcessStep(master, 'I@glusterfs:server', 'cmd.run', ['gluster volume status']) |
| 186 | // Install haproxy |
| 187 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'state.sls', ['haproxy']) |
| 188 | salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| 189 | // Install docker |
| 190 | salt.runSaltProcessStep(master, 'I@docker:host', 'state.sls', ['docker.host']) |
| 191 | salt.runSaltProcessStep(master, 'I@docker:host', 'cmd.run', ['docker ps']) |
| 192 | // Install bird |
| 193 | salt.runSaltProcessStep(master, 'I@bird:server', 'state.sls', ['bird']) |
| 194 | // Install etcd |
| 195 | salt.runSaltProcessStep(master, 'I@etcd:server', 'state.sls', ['etcd.server.service']) |
| 196 | salt.runSaltProcessStep(master, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health']) |
| 197 | } |
| 198 | |
| 199 | |
| 200 | def installOpenstackMcpControl(master) { |
| 201 | def salt = new com.mirantis.mk.Salt() |
| 202 | // Install Kubernetes pool and Calico |
| 203 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool']) |
| 204 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status']) |
| 205 | |
| 206 | // Setup etcd server |
| 207 | salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup']) |
| 208 | |
| 209 | // Run k8s without master.setup |
| 210 | salt.runSaltProcessStep(master, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup']) |
| 211 | |
| 212 | // Run k8s master setup |
| 213 | salt.runSaltProcessStep(master, 'ctl01*', 'state.sls', ['kubernetes.master.setup']) |
| 214 | |
| 215 | // Revert comment nameserver |
| 216 | salt.runSaltProcessStep(master, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"]) |
| 217 | |
| 218 | // Set route |
| 219 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4']) |
| 220 | |
| 221 | // Restart kubelet |
| 222 | salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
| 223 | } |
| 224 | |
| 225 | |
| 226 | def installOpenstackMcpCompute(master) { |
| 227 | def salt = new com.mirantis.mk.Salt(); |
| 228 | // Install opencontrail |
| 229 | salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'state.sls', ['opencontrail']) |
| 230 | // Reboot compute nodes |
| 231 | salt.runSaltProcessStep(master, 'I@opencontrail:compute', 'system.reboot') |
| 232 | } |
| 233 | |
| 234 | |
| 235 | def installStacklightControl(master) { |
| 236 | def salt = new com.mirantis.mk.Salt(); |
| 237 | salt.runSaltProcessStep(master, 'I@elasticsearch:server', 'state.sls', ['elasticsearch.server']) |
| 238 | salt.runSaltProcessStep(master, 'I@influxdb:server', 'state.sls', ['influxdb']) |
| 239 | salt.runSaltProcessStep(master, 'I@kibana:server', 'state.sls', ['kibana.server']) |
| 240 | salt.runSaltProcessStep(master, 'I@grafana:server', 'state.sls', ['grafana']) |
| 241 | salt.runSaltProcessStep(master, 'I@nagios:server', 'state.sls', ['nagios']) |
| 242 | salt.runSaltProcessStep(master, 'I@elasticsearch:client', 'state.sls', ['elasticsearch.client']) |
| 243 | salt.runSaltProcessStep(master, 'I@kibana:client', 'state.sls', ['kibana.client']) |
Tomáš Kukrál | f06ca0f | 2017-02-27 15:18:50 +0100 | [diff] [blame] | 244 | } |