| package com.mirantis.mk |
| /** |
| * Orchestration functions |
| * |
| */ |
| |
| def validateFoundationInfra(master) { |
| def salt = new com.mirantis.mk.Salt() |
| |
| salt.cmdRun(master, 'I@salt:master' ,'salt-key') |
| salt.runSaltProcessStep(master, 'I@salt:minion', 'test.version') |
| salt.cmdRun(master, 'I@salt:master' ,'reclass-salt --top') |
| salt.runSaltProcessStep(master, 'I@reclass:storage', 'reclass.inventory') |
| salt.runSaltProcessStep(master, 'I@salt:minion', 'state.show_top') |
| } |
| |
| def installFoundationInfra(master, staticMgmtNet=false) { |
| def salt = new com.mirantis.mk.Salt() |
| def common = new com.mirantis.mk.Common() |
| |
| // NOTE(vsaienko) Apply reclass first, it may update cluster model |
| // apply linux and salt.master salt.minion states afterwards to make sure |
| // correct cluster model is used. |
| salt.enforceState(master, 'I@salt:master', ['reclass']) |
| |
| salt.enforceState(master, 'I@salt:master', ['linux.system']) |
| salt.enforceState(master, 'I@salt:master', ['salt.master'], true, false, null, false, 120, 2) |
| salt.fullRefresh(master, "*") |
| |
| salt.enforceState(master, 'I@salt:master', ['salt.minion'], true, false, null, false, 60, 2) |
| salt.enforceState(master, 'I@salt:master', ['salt.minion']) |
| salt.fullRefresh(master, "*") |
| salt.enforceState(master, '*', ['linux.network.proxy'], true, false, null, false, 60, 2) |
| try { |
| salt.enforceState(master, '*', ['salt.minion.base'], true, false, null, false, 60, 2) |
| sleep(5) |
| } catch (Throwable e) { |
| common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.') |
| } |
| salt.enforceState(master, '*', ['linux.system']) |
| if (staticMgmtNet) { |
| salt.runSaltProcessStep(master, '*', 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| } |
| salt.enforceState(master, 'I@linux:network:interface', ['linux.network.interface']) |
| sleep(5) |
| salt.enforceState(master, 'I@linux:system', ['linux', 'openssh', 'ntp', 'rsyslog']) |
| salt.enforceState(master, '*', ['salt.minion'], true, false, null, false, 60, 2) |
| sleep(5) |
| |
| salt.fullRefresh(master, "*") |
| salt.runSaltProcessStep(master, '*', 'mine.update', [], null, true) |
| salt.enforceState(master, '*', ['linux.network.host']) |
| |
| // Install and configure iptables |
| if (salt.testTarget(master, 'I@iptables:service')) { |
| salt.enforceState(master, 'I@iptables:service', 'iptables') |
| } |
| |
| // Install and configure logrotate |
| if (salt.testTarget(master, 'I@logrotate:server')) { |
| salt.enforceState(master, 'I@logrotate:server', 'logrotate') |
| } |
| } |
| |
| def installFoundationInfraOnTarget(master, target, staticMgmtNet=false) { |
| def salt = new com.mirantis.mk.Salt() |
| def common = new com.mirantis.mk.Common() |
| |
| salt.enforceState(master, 'I@salt:master', ['reclass'], true, false, null, false, 120, 2) |
| salt.fullRefresh(master, target) |
| salt.enforceState(master, target, ['linux.network.proxy'], true, false, null, false, 60, 2) |
| try { |
| salt.enforceState(master, target, ['salt.minion.base'], true, false, null, false, 60, 2) |
| sleep(5) |
| } catch (Throwable e) { |
| common.warningMsg('Salt state salt.minion.base is not present in the Salt-formula yet.') |
| } |
| salt.enforceState(master, target, ['linux.system']) |
| if (staticMgmtNet) { |
| salt.runSaltProcessStep(master, target, 'cmd.shell', ["salt-call state.sls linux.network; salt-call service.restart salt-minion"], null, true, 60) |
| } |
| salt.enforceState(master, target, ['salt.minion'], true, false, null, false, 60, 2) |
| salt.enforceState(master, target, ['salt.minion']) |
| salt.enforceState(master, target, ['linux.network.interface']) |
| sleep(5) |
| salt.enforceState(master, target, ['linux', 'openssh', 'ntp', 'rsyslog']) |
| sleep(5) |
| |
| salt.fullRefresh(master, target) |
| salt.runSaltProcessStep(master, target, 'mine.update', [], null, true) |
| salt.enforceState(master, target, ['linux.network.host']) |
| } |
| |
| def installInfraKvm(master) { |
| def common = new com.mirantis.mk.Common() |
| def salt = new com.mirantis.mk.Salt() |
| salt.fullRefresh(master, 'I@linux:system') |
| def infra_conpund = 'I@salt:control' |
| def minions = [] |
| def wait_timeout = 10 |
| def retries = wait_timeout * 30 |
| |
| salt.enforceState(master, 'I@salt:control', ['salt.minion'], true, false, null, false, 60, 2) |
| salt.enforceState(master, 'I@salt:control', ['linux.system', 'linux.network', 'ntp', 'rsyslog']) |
| salt.enforceState(master, 'I@salt:control', 'libvirt') |
| salt.enforceState(master, 'I@salt:control', 'salt.control') |
| |
| timeout(wait_timeout) { |
| common.infoMsg("Waiting for minions to come up...") |
| if (salt.testTarget(master, infra_conpund)) { |
| // Gathering minions |
| for ( infra_node in salt.getMinionsSorted(master, infra_conpund) ) { |
| def pillar = salt.getPillar(master, infra_node, 'salt:control:cluster') |
| if ( !pillar['return'].isEmpty() ) { |
| for ( cluster in pillar['return'][0].values() ) { |
| def engine = cluster.values()[0]['engine'] |
| def domain = cluster.values()[0]['domain'] |
| def node = cluster.values()[0]['node'] |
| if ( engine == "virt" ) { |
| def nodes = node.values() |
| if ( !nodes.isEmpty() ) { |
| for ( vm in nodes ) { |
| if ( vm['name'] != null ) { |
| def vm_fqdn = vm['name'] + '.' + domain |
| if ( !minions.contains(vm_fqdn) ) { |
| minions.add(vm_fqdn) |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| def minions_compound = minions.join(' or ') |
| common.infoMsg('Waiting for next minions to register: ' + minions_compound,) |
| salt.minionsPresentFromList(master, 'I@salt:master', minions, true, null, true, retries, 1) |
| common.infoMsg('Waiting for minions to respond') |
| salt.minionsReachable(master, 'I@salt:master', minions_compound ) |
| |
| } |
| |
| common.infoMsg("All minions are up.") |
| salt.fullRefresh(master, '* and not kvm*') |
| |
| } |
| |
| def installInfra(master) { |
| def common = new com.mirantis.mk.Common() |
| def salt = new com.mirantis.mk.Salt() |
| |
| // Install glusterfs |
| if (salt.testTarget(master, 'I@glusterfs:server')) { |
| salt.enforceState(master, 'I@glusterfs:server', 'glusterfs.server.service') |
| |
| salt.enforceState(master, 'I@glusterfs:server and *01*', 'glusterfs.server.setup', true, true, null, false, -1, 5) |
| sleep(10) |
| salt.cmdRun(master, 'I@glusterfs:server', "gluster peer status; gluster volume status") |
| } |
| |
| // Ensure glusterfs clusters is ready |
| if (salt.testTarget(master, 'I@glusterfs:client')) { |
| salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client') |
| } |
| |
| // Install galera |
| if (salt.testTarget(master, 'I@galera:master') || salt.testTarget(master, 'I@galera:slave')) { |
| salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2) |
| salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2) |
| |
| // Check galera status |
| salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
| // If galera is not enabled check if we need to install mysql:server |
| } else if (salt.testTarget(master, 'I@mysql:server')){ |
| salt.enforceState(master, 'I@mysql:server', 'mysql.server') |
| if (salt.testTarget(master, 'I@mysql:client')){ |
| salt.enforceState(master, 'I@mysql:client', 'mysql.client') |
| } |
| } |
| installBackup(master, 'mysql') |
| |
| // Install docker |
| if (salt.testTarget(master, 'I@docker:host')) { |
| salt.enforceState(master, 'I@docker:host', 'docker.host') |
| salt.cmdRun(master, 'I@docker:host', 'docker ps') |
| } |
| |
| // Install keepalived |
| if (salt.testTarget(master, 'I@keepalived:cluster')) { |
| salt.enforceState(master, 'I@keepalived:cluster and *01*', 'keepalived') |
| salt.enforceState(master, 'I@keepalived:cluster', 'keepalived') |
| } |
| |
| // Install rabbitmq |
| if (salt.testTarget(master, 'I@rabbitmq:server')) { |
| salt.enforceState(master, 'I@rabbitmq:server', 'rabbitmq', true, true, null, false, -1, 2) |
| |
| // Check the rabbitmq status |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@rabbitmq:server', 'rabbitmqctl cluster_status') |
| } |
| } |
| |
| // Install haproxy |
| if (salt.testTarget(master, 'I@haproxy:proxy')) { |
| salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
| salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.restart', ['rsyslog']) |
| } |
| |
| // Install memcached |
| if (salt.testTarget(master, 'I@memcached:server')) { |
| salt.enforceState(master, 'I@memcached:server', 'memcached') |
| } |
| |
| // Install etcd |
| if (salt.testTarget(master, 'I@etcd:server')) { |
| salt.enforceState(master, 'I@etcd:server', 'etcd.server.service') |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@etcd:server', '. /var/lib/etcd/configenv && etcdctl cluster-health') |
| } |
| } |
| |
| // Install redis |
| if (salt.testTarget(master, 'I@redis:server')) { |
| if (salt.testTarget(master, 'I@redis:cluster:role:master')) { |
| salt.enforceState(master, 'I@redis:cluster:role:master', 'redis') |
| } |
| salt.enforceState(master, 'I@redis:server', 'redis') |
| } |
| installBackup(master, 'common') |
| } |
| |
| def installOpenstackInfra(master) { |
| def common = new com.mirantis.mk.Common() |
| common.warningMsg("You calling orchestrate.installOpenstackInfra(). This function is deprecated please use orchestrate.installInfra() directly") |
| installInfra(master) |
| } |
| |
| |
| def installOpenstackControl(master) { |
| def salt = new com.mirantis.mk.Salt() |
| def common = new com.mirantis.mk.Common() |
| |
| // Install horizon dashboard |
| if (salt.testTarget(master, 'I@horizon:server')) { |
| salt.enforceState(master, 'I@horizon:server', 'horizon') |
| } |
| // Install sphinx server |
| if (salt.testTarget(master, 'I@sphinx:server')) { |
| salt.enforceState(master, 'I@sphinx:server', 'sphinx') |
| } |
| if (salt.testTarget(master, 'I@nginx:server')) { |
| salt.enforceState(master, 'I@nginx:server', 'salt.minion') |
| salt.enforceState(master, 'I@nginx:server', 'nginx') |
| } |
| |
| // setup keystone service |
| if (salt.testTarget(master, 'I@keystone:server')) { |
| salt.enforceState(master, 'I@keystone:server and *01*', 'keystone.server') |
| salt.enforceState(master, 'I@keystone:server', 'keystone.server') |
| // populate keystone services/tenants/roles/users |
| |
| // keystone:client must be called locally |
| //salt.runSaltProcessStep(master, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true) |
| salt.runSaltProcessStep(master, 'I@keystone:server', 'service.restart', ['apache2']) |
| sleep(30) |
| } |
| if (salt.testTarget(master, 'I@keystone:client')) { |
| salt.enforceState(master, 'I@keystone:client and *01*', 'keystone.client') |
| salt.enforceState(master, 'I@keystone:client', 'keystone.client') |
| } |
| if (salt.testTarget(master, 'I@keystone:server')) { |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; openstack service list') |
| } |
| } |
| |
| // Install glance |
| if (salt.testTarget(master, 'I@glance:server')) { |
| //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1) |
| salt.enforceState(master, 'I@glance:server and *01*', 'glance.server') |
| salt.enforceState(master, 'I@glance:server', 'glance.server') |
| } |
| |
| // Check glance service |
| if (salt.testTarget(master, 'I@glance:server')){ |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; glance image-list') |
| } |
| } |
| |
| // Create glance resources |
| if (salt.testTarget(master, 'I@glance:client')) { |
| salt.enforceState(master, 'I@glance:client', 'glance.client') |
| } |
| |
| // Install and check nova service |
| if (salt.testTarget(master, 'I@nova:controller')) { |
| // run on first node first |
| salt.enforceState(master, 'I@nova:controller and *01*', 'nova.controller') |
| salt.enforceState(master, 'I@nova:controller', 'nova.controller') |
| if (salt.testTarget(master, 'I@keystone:server')) { |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; nova service-list') |
| } |
| } |
| } |
| |
| // Create nova resources |
| if (salt.testTarget(master, 'I@nova:client')) { |
| salt.enforceState(master, 'I@nova:client', 'nova.client') |
| } |
| |
| // Install and check cinder service |
| if (salt.testTarget(master, 'I@cinder:controller')) { |
| // run on first node first |
| salt.enforceState(master, 'I@cinder:controller and *01*', 'cinder') |
| salt.enforceState(master, 'I@cinder:controller', 'cinder') |
| if (salt.testTarget(master, 'I@keystone:server')) { |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; cinder list') |
| } |
| } |
| } |
| |
| // Install neutron service |
| if (salt.testTarget(master, 'I@neutron:server')) { |
| // run on first node first |
| salt.enforceState(master, 'I@neutron:server and *01*', 'neutron.server') |
| salt.enforceState(master, 'I@neutron:server', 'neutron.server') |
| if (salt.testTarget(master, 'I@keystone:server')) { |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@keystone:server','. /root/keystonercv3; neutron agent-list') |
| } |
| } |
| } |
| |
| // Install heat service |
| if (salt.testTarget(master, 'I@heat:server')) { |
| // run on first node first |
| salt.enforceState(master, 'I@heat:server and *01*', 'heat') |
| salt.enforceState(master, 'I@heat:server', 'heat') |
| if (salt.testTarget(master, 'I@keystone:server')) { |
| common.retry(3,5){ |
| salt.cmdRun(master, 'I@keystone:server', '. /root/keystonercv3; heat resource-type-list') |
| } |
| } |
| } |
| |
| // Restart nova api |
| if (salt.testTarget(master, 'I@nova:controller')) { |
| salt.runSaltProcessStep(master, 'I@nova:controller', 'service.restart', ['nova-api']) |
| } |
| |
| // Install ironic service |
| if (salt.testTarget(master, 'I@ironic:api')) { |
| salt.enforceState(master, 'I@ironic:api and *01*', 'ironic.api') |
| salt.enforceState(master, 'I@ironic:api', 'ironic.api') |
| } |
| |
| // Install manila service |
| if (salt.testTarget(master, 'I@manila:api')) { |
| salt.enforceState(master, 'I@manila:api and *01*', 'manila.api') |
| salt.enforceState(master, 'I@manila:api', 'manila.api') |
| } |
| if (salt.testTarget(master, 'I@manila:scheduler')) { |
| salt.enforceState(master, 'I@manila:scheduler', 'manila.scheduler') |
| } |
| |
| // Install designate services |
| if (salt.testTarget(master, 'I@designate:server:enabled')) { |
| if (salt.testTarget(master, 'I@designate:server:backend:bind9')) { |
| salt.enforceState(master, 'I@bind:server', 'bind.server') |
| } |
| if (salt.testTarget(master, 'I@designate:server:backend:pdns4')) { |
| salt.enforceState(master, 'I@powerdns:server', 'powerdns.server') |
| } |
| salt.enforceState(master, 'I@designate:server and *01*', 'designate.server') |
| salt.enforceState(master, 'I@designate:server', 'designate') |
| } |
| |
| // Install octavia api service |
| if (salt.testTarget(master, 'I@octavia:api')) { |
| salt.enforceState(master, 'I@octavia:api and *01*', 'octavia') |
| salt.enforceState(master, 'I@octavia:api', 'octavia') |
| } |
| |
| // Install DogTag server service |
| if (salt.testTarget(master, 'I@dogtag:server')) { |
| salt.enforceState(master, 'I@dogtag:server and *01*', 'dogtag.server') |
| salt.enforceState(master, 'I@dogtag:server', 'dogtag.server') |
| } |
| |
| // Install barbican server service |
| if (salt.testTarget(master, 'I@barbican:server')) { |
| salt.enforceState(master, 'I@barbican:server and *01*', 'barbican.server') |
| salt.enforceState(master, 'I@barbican:server', 'barbican.server') |
| } |
| // Install barbican client |
| if (salt.testTarget(master, 'I@barbican:client')) { |
| salt.enforceState(master, 'I@barbican:client', 'barbican.client') |
| } |
| |
| // Install gnocchi server |
| if (salt.testTarget(master, 'I@gnocchi:server')) { |
| salt.enforceState(master, 'I@gnocchi:server and *01*', 'gnocchi.server') |
| salt.enforceState(master, 'I@gnocchi:server', 'gnocchi.server') |
| } |
| |
| // Install gnocchi statsd |
| if (salt.testTarget(master, 'I@gnocchi:statsd')) { |
| salt.enforceState(master, 'I@gnocchi:statsd and *01*', 'gnocchi.statsd') |
| salt.enforceState(master, 'I@gnocchi:statsd', 'gnocchi.statsd') |
| } |
| |
| // Install panko server |
| if (salt.testTarget(master, 'I@panko:server')) { |
| salt.enforceState(master, 'I@panko:server and *01*', 'panko') |
| salt.enforceState(master, 'I@panko:server', 'panko') |
| } |
| |
| // Install ceilometer server |
| if (salt.testTarget(master, 'I@ceilometer:server')) { |
| salt.enforceState(master, 'I@ceilometer:server and *01*', 'ceilometer') |
| salt.enforceState(master, 'I@ceilometer:server', 'ceilometer') |
| } |
| |
| // Install aodh server |
| if (salt.testTarget(master, 'I@aodh:server')) { |
| salt.enforceState(master, 'I@aodh:server and *01*', 'aodh') |
| salt.enforceState(master, 'I@aodh:server', 'aodh') |
| } |
| } |
| |
| |
| def installIronicConductor(master){ |
| def salt = new com.mirantis.mk.Salt() |
| |
| if (salt.testTarget(master, 'I@ironic:conductor')) { |
| salt.enforceState(master, 'I@ironic:conductor', 'ironic.conductor') |
| salt.enforceState(master, 'I@ironic:conductor', 'apache') |
| } |
| if (salt.testTarget(master, 'I@tftpd_hpa:server')) { |
| salt.enforceState(master, 'I@tftpd_hpa:server', 'tftpd_hpa') |
| } |
| |
| if (salt.testTarget(master, 'I@nova:compute')) { |
| salt.runSaltProcessStep(master, 'I@nova:compute', 'service.restart', ['nova-compute']) |
| } |
| |
| if (salt.testTarget(master, 'I@baremetal_simulator:enabled')) { |
| salt.enforceState(master, 'I@baremetal_simulator:enabled', 'baremetal_simulator') |
| } |
| if (salt.testTarget(master, 'I@ironic:client')) { |
| salt.enforceState(master, 'I@ironic:client', 'ironic.client') |
| } |
| } |
| |
| def installManilaShare(master){ |
| def salt = new com.mirantis.mk.Salt() |
| |
| if (salt.testTarget(master, 'I@manila:share')) { |
| salt.enforceState(master, 'I@manila:share', 'manila.share') |
| } |
| if (salt.testTarget(master, 'I@manila:data')) { |
| salt.enforceState(master, 'I@manila:data', 'manila.data') |
| } |
| |
| if (salt.testTarget(master, 'I@manila:client')) { |
| salt.enforceState(master, 'I@manila:client', 'manila.client') |
| } |
| } |
| |
| |
| def installOpenstackNetwork(master, physical = "false") { |
| def salt = new com.mirantis.mk.Salt() |
| //run full neutron state on neutron.gateway - this will install |
| //neutron agents in addition to neutron server. Once neutron agents |
| //are up neutron resources can be created without hitting the situation when neutron resources are created |
| //prior to neutron agents which results in creating ports in non-usable state |
| if (salt.testTarget(master, 'I@neutron:gateway')) { |
| salt.enforceState(master, 'I@neutron:gateway', 'neutron') |
| } |
| |
| // Create neutron resources - this step was moved here to ensure that |
| //neutron resources are created after neutron agens are up. In this case neutron ports will be in |
| //usable state. More information: https://bugs.launchpad.net/neutron/+bug/1399249 |
| if (salt.testTarget(master, 'I@neutron:client')) { |
| salt.enforceState(master, 'I@neutron:client', 'neutron.client') |
| } |
| |
| salt.enforceHighstate(master, 'I@neutron:gateway') |
| |
| // install octavia manager services |
| if (salt.testTarget(master, 'I@octavia:manager')) { |
| salt.runSaltProcessStep(master, 'I@salt:master', 'mine.update', ['*']) |
| salt.enforceState(master, 'I@octavia:manager', 'octavia') |
| salt.enforceState(master, 'I@octavia:manager', 'salt.minion.ca') |
| salt.enforceState(master, 'I@octavia:manager', 'salt.minion.cert') |
| } |
| } |
| |
| |
| def installOpenstackCompute(master) { |
| def salt = new com.mirantis.mk.Salt() |
| // Configure compute nodes |
| def compute_compound = 'I@nova:compute' |
| if (salt.testTarget(master, compute_compound)) { |
| // In case if infrastructure nodes are used as nova computes too |
| def gluster_compound = 'I@glusterfs:server' |
| def salt_ca_compound = 'I@salt:minion:ca:salt_master_ca' |
| // Enforce highstate asynchronous only on compute nodes which are not glusterfs and not salt ca servers |
| def hightstateTarget = "${compute_compound} and not ${gluster_compound} and not ${salt_ca_compound}" |
| if (salt.testTarget(master, hightstateTarget)) { |
| retry(2) { |
| salt.enforceHighstateWithExclude(master, hightstateTarget, 'opencontrail.client') |
| } |
| } |
| // Iterate through salt ca servers and check if they have compute role |
| // TODO: switch to batch once salt 2017.7+ would be used |
| for ( target in salt.getMinionsSorted(master, salt_ca_compound) ) { |
| for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) { |
| if ( target == cmp_target ) { |
| // Enforce highstate one by one on salt ca servers which are compute nodes |
| retry(2) { |
| salt.enforceHighstateWithExclude(master, target, 'opencontrail.client') |
| } |
| } |
| } |
| } |
| // Iterate through glusterfs servers and check if they have compute role |
| // TODO: switch to batch once salt 2017.7+ would be used |
| for ( target in salt.getMinionsSorted(master, gluster_compound) ) { |
| for ( cmp_target in salt.getMinionsSorted(master, compute_compound) ) { |
| if ( target == cmp_target ) { |
| // Enforce highstate one by one on glusterfs servers which are compute nodes |
| retry(2) { |
| salt.enforceHighstateWithExclude(master, target, 'opencontrail.client') |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| def installContrailNetwork(master) { |
| def common = new com.mirantis.mk.Common() |
| def salt = new com.mirantis.mk.Salt() |
| |
| |
| // Install opencontrail database services |
| salt.enforceState(master, 'I@opencontrail:database and *01*', 'opencontrail.database') |
| salt.enforceState(master, 'I@opencontrail:database', 'opencontrail.database') |
| |
| // Install opencontrail control services |
| salt.enforceStateWithExclude(master, "I@opencontrail:control and *01*", "opencontrail", "opencontrail.client") |
| salt.enforceStateWithExclude(master, "I@opencontrail:control", "opencontrail", "opencontrail.client") |
| salt.enforceStateWithExclude(master, "I@opencontrail:collector and *01*", "opencontrail", "opencontrail.client") |
| |
| if (salt.testTarget(master, 'I@docker:client and I@opencontrail:control')) { |
| salt.enforceState(master, 'I@opencontrail:control or I@opencontrail:collector', 'docker.client') |
| } |
| installBackup(master, 'contrail') |
| } |
| |
| |
| def installContrailCompute(master) { |
| def salt = new com.mirantis.mk.Salt() |
| def common = new com.mirantis.mk.Common() |
| // Configure compute nodes |
| // Provision opencontrail control services |
| salt.enforceState(master, 'I@opencontrail:database:id:1', 'opencontrail.client') |
| // Provision opencontrail virtual routers |
| |
| // Generate script /usr/lib/contrail/if-vhost0 for up vhost0 |
| if (salt.testTarget(master, 'I@opencontrail:compute')) { |
| salt.enforceStateWithExclude(master, "I@opencontrail:compute", "opencontrail", "opencontrail.client") |
| } |
| |
| if (salt.testTarget(master, 'I@nova:compute')) { |
| 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) |
| } |
| |
| sleep(300) |
| if (salt.testTarget(master, 'I@opencontrail:compute')) { |
| salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail.client') |
| salt.enforceState(master, 'I@opencontrail:compute', 'opencontrail') |
| } |
| } |
| |
| |
| def installKubernetesInfra(master) { |
| def common = new com.mirantis.mk.Common() |
| common.warningMsg("You calling orchestrate.installKubernetesInfra(). This function is deprecated please use orchestrate.installInfra() directly") |
| installInfra(master) |
| } |
| |
| |
| def installKubernetesControl(master) { |
| def salt = new com.mirantis.mk.Salt() |
| |
| // Install Kubernetes pool and Calico |
| salt.enforceState(master, 'I@kubernetes:master', 'kubernetes.master.kube-addons') |
| salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
| |
| if (salt.testTarget(master, 'I@etcd:server:setup')) { |
| // Setup etcd server |
| salt.enforceState(master, 'I@kubernetes:master and *01*', 'etcd.server.setup') |
| } |
| |
| // Run k8s master at *01* to simplify namespaces creation |
| salt.enforceStateWithExclude(master, 'I@kubernetes:master and *01*', "kubernetes.master", "kubernetes.master.setup") |
| |
| // Run k8s without master.setup |
| salt.enforceStateWithExclude(master, 'I@kubernetes:master', "kubernetes", "kubernetes.master.setup") |
| |
| // Run k8s master setup |
| salt.enforceState(master, 'I@kubernetes:master and *01*', 'kubernetes.master.setup') |
| |
| // Restart kubelet |
| salt.runSaltProcessStep(master, 'I@kubernetes:pool', 'service.restart', ['kubelet']) |
| } |
| |
| |
| def installKubernetesCompute(master) { |
| def salt = new com.mirantis.mk.Salt() |
| salt.fullRefresh(master, "*") |
| |
| // Bootstrap all nodes |
| salt.enforceState(master, 'I@kubernetes:pool', 'linux') |
| salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion') |
| salt.enforceState(master, 'I@kubernetes:pool', ['openssh', 'ntp']) |
| |
| // Create and distribute SSL certificates for services using salt state |
| salt.enforceState(master, 'I@kubernetes:pool', 'salt.minion.cert') |
| |
| // Install docker |
| salt.enforceState(master, 'I@docker:host', 'docker.host') |
| |
| // Install Kubernetes and Calico |
| salt.enforceState(master, 'I@kubernetes:pool', 'kubernetes.pool') |
| |
| // Install Tiller and all configured releases |
| if (salt.testTarget(master, 'I@helm:client')) { |
| salt.enforceState(master, 'I@helm:client', 'helm') |
| } |
| } |
| |
| |
| def installDockerSwarm(master) { |
| def salt = new com.mirantis.mk.Salt() |
| |
| //Install and Configure Docker |
| salt.enforceState(master, 'I@docker:swarm', 'docker.host') |
| salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm') |
| salt.enforceState(master, 'I@docker:swarm', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, 'I@docker:swarm', 'mine.update') |
| salt.runSaltProcessStep(master, 'I@docker:swarm', 'saltutil.refresh_modules') |
| sleep(5) |
| salt.enforceState(master, 'I@docker:swarm:role:master', 'docker.swarm') |
| salt.enforceState(master, 'I@docker:swarm:role:manager', 'docker.swarm') |
| sleep(10) |
| salt.cmdRun(master, 'I@docker:swarm:role:master', 'docker node ls') |
| } |
| |
| |
| def installCicd(master) { |
| def salt = new com.mirantis.mk.Salt() |
| def common = new com.mirantis.mk.Common() |
| def gerrit_compound = 'I@gerrit:client and ci*' |
| def jenkins_compound = 'I@jenkins:client and ci*' |
| |
| salt.fullRefresh(master, gerrit_compound) |
| salt.fullRefresh(master, jenkins_compound) |
| |
| if (salt.testTarget(master, 'I@aptly:publisher')) { |
| salt.enforceState(master, 'I@aptly:publisher', 'aptly.publisher',true, null, false, -1, 2) |
| } |
| |
| salt.enforceState(master, 'I@docker:swarm:role:master and I@jenkins:client', 'docker.client', true, true, null, false, -1, 2) |
| |
| // API timeout in minutes |
| def wait_timeout = 10 |
| |
| // Gerrit |
| def gerrit_master_url = salt.getPillar(master, gerrit_compound, '_param:gerrit_master_url') |
| |
| if(!gerrit_master_url['return'].isEmpty()) { |
| gerrit_master_url = gerrit_master_url['return'][0].values()[0] |
| } else { |
| gerrit_master_url = '' |
| } |
| |
| if (gerrit_master_url != '') { |
| common.infoMsg('Gerrit master url "' + gerrit_master_url + '" retrieved at _param:gerrit_master_url') |
| } else { |
| |
| common.infoMsg('Gerrit master url could not be retrieved at _param:gerrit_master_url. Falling back to gerrit pillar') |
| |
| def gerrit_host |
| def gerrit_http_port |
| def gerrit_http_scheme |
| |
| def host_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:host') |
| gerrit_host = salt.getReturnValues(host_pillar) |
| |
| def port_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:http_port') |
| gerrit_http_port = salt.getReturnValues(port_pillar) |
| |
| def scheme_pillar = salt.getPillar(master, gerrit_compound, 'gerrit:client:server:protocol') |
| gerrit_http_scheme = salt.getReturnValues(scheme_pillar) |
| |
| gerrit_master_url = gerrit_http_scheme + '://' + gerrit_host + ':' + gerrit_http_port |
| |
| } |
| |
| timeout(wait_timeout) { |
| common.infoMsg('Waiting for Gerrit to come up..') |
| def check_gerrit_cmd = 'while true; do curl -sI -m 3 -o /dev/null -w' + " '" + '%{http_code}' + "' " + gerrit_master_url + '/ | grep 200 && break || sleep 1; done' |
| salt.cmdRun(master, gerrit_compound, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_gerrit_cmd + '"') |
| } |
| |
| // Jenkins |
| def jenkins_master_url_pillar = salt.getPillar(master, jenkins_compound, '_param:jenkins_master_url') |
| jenkins_master_url = salt.getReturnValues(jenkins_master_url_pillar) |
| |
| timeout(wait_timeout) { |
| common.infoMsg('Waiting for Jenkins to come up..') |
| def check_jenkins_cmd = 'while true; do curl -sI -m 3 -o /dev/null -w' + " '" + '%{http_code}' + "' " + jenkins_master_url + '/whoAmI/ | grep 200 && break || sleep 1; done' |
| salt.cmdRun(master, jenkins_compound, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_jenkins_cmd + '"') |
| } |
| |
| if (salt.testTarget(master, 'I@aptly:server')) { |
| salt.enforceState(master, 'I@aptly:server', 'aptly', true, true, null, false, -1, 2) |
| } |
| |
| if (salt.testTarget(master, 'I@openldap:client')) { |
| salt.enforceState(master, 'I@openldap:client', 'openldap', true, true, null, false, -1, 2) |
| } |
| |
| if (salt.testTarget(master, 'I@python:environment')) { |
| salt.enforceState(master, 'I@python:environment', 'python') |
| } |
| |
| withEnv(['ASK_ON_ERROR=false']){ |
| retry(2){ |
| try{ |
| salt.enforceState(master, 'I@gerrit:client', 'gerrit') |
| }catch(e){ |
| salt.fullRefresh(master, 'I@gerrit:client') |
| throw e //rethrow for retry handler |
| } |
| } |
| retry(2){ |
| try{ |
| salt.enforceState(master, 'I@jenkins:client', 'jenkins') |
| }catch(e){ |
| salt.fullRefresh(master, 'I@jenkins:client') |
| throw e //rethrow for retry handler |
| } |
| } |
| } |
| } |
| |
| |
| def installStacklight(master) { |
| def common = new com.mirantis.mk.Common() |
| def salt = new com.mirantis.mk.Salt() |
| |
| // Install core services for K8S environments: |
| // HAProxy, Nginx and lusterFS clients |
| // In case of OpenStack, those are already installed |
| if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| salt.enforceState(master, 'I@haproxy:proxy', 'haproxy') |
| salt.runSaltProcessStep(master, 'I@haproxy:proxy', 'service.status', ['haproxy']) |
| |
| if (salt.testTarget(master, 'I@nginx:server')) { |
| salt.enforceState(master, 'I@nginx:server', 'nginx') |
| } |
| |
| if (salt.testTarget(master, 'I@glusterfs:client')) { |
| salt.enforceState(master, 'I@glusterfs:client', 'glusterfs.client') |
| } |
| } |
| |
| // Install MongoDB for Alerta |
| if (salt.testTarget(master, 'I@mongodb:server')) { |
| salt.enforceState(master, 'I@mongodb:server', 'mongodb') |
| } |
| |
| //Install Telegraf |
| salt.enforceState(master, 'I@telegraf:agent or I@telegraf:remote_agent', 'telegraf') |
| |
| // Install Prometheus exporters |
| if (salt.testTarget(master, 'I@prometheus:exporters')) { |
| salt.enforceState(master, 'I@prometheus:exporters', 'prometheus') |
| } |
| |
| //Install Elasticsearch and Kibana |
| salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server') |
| salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server') |
| salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server') |
| salt.enforceState(master, 'I@kibana:server', 'kibana.server') |
| salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client') |
| salt.enforceState(master, 'I@kibana:client', 'kibana.client') |
| |
| //Install InfluxDB |
| if (salt.testTarget(master, 'I@influxdb:server')) { |
| salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb') |
| salt.enforceState(master, 'I@influxdb:server', 'influxdb') |
| } |
| |
| // Install service for the log collection |
| if (salt.testTarget(master, 'I@fluentd:agent')) { |
| salt.enforceState(master, 'I@fluentd:agent', 'fluentd') |
| } else { |
| salt.enforceState(master, 'I@heka:log_collector', 'heka.log_collector') |
| } |
| |
| // Install heka ceilometer collector |
| if (salt.testTarget(master, 'I@heka:ceilometer_collector:enabled')) { |
| salt.enforceState(master, 'I@heka:ceilometer_collector:enabled', 'heka.ceilometer_collector') |
| salt.runSaltProcessStep(master, 'I@heka:ceilometer_collector:enabled', 'service.restart', ['ceilometer_collector'], null, true) |
| } |
| |
| // Install galera |
| if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| salt.enforceState(master, 'I@galera:master', 'galera', true, true, null, false, -1, 2) |
| salt.enforceState(master, 'I@galera:slave', 'galera', true, true, null, false, -1, 2) |
| |
| // Check galera status |
| salt.runSaltProcessStep(master, 'I@galera:master', 'mysql.status') |
| salt.runSaltProcessStep(master, 'I@galera:slave', 'mysql.status') |
| } |
| |
| //Collect Grains |
| salt.enforceState(master, 'I@salt:minion', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, 'I@salt:minion', 'saltutil.refresh_modules') |
| salt.runSaltProcessStep(master, 'I@salt:minion', 'mine.update') |
| sleep(5) |
| |
| // Configure Prometheus in Docker Swarm |
| salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'prometheus') |
| |
| //Configure Remote Collector in Docker Swarm for Openstack deployments |
| if (!common.checkContains('STACK_INSTALL', 'k8s')) { |
| salt.enforceState(master, 'I@docker:swarm and I@prometheus:server', 'heka.remote_collector', true, false) |
| } |
| |
| // Launch containers |
| salt.enforceState(master, 'I@docker:swarm:role:master and I@prometheus:server', 'docker.client') |
| salt.runSaltProcessStep(master, 'I@docker:swarm and I@prometheus:server', 'dockerng.ps') |
| |
| //Install Prometheus LTS |
| if (salt.testTarget(master, 'I@prometheus:relay')) { |
| salt.enforceState(master, 'I@prometheus:relay', 'prometheus') |
| } |
| |
| // Install sphinx server |
| if (salt.testTarget(master, 'I@sphinx:server')) { |
| salt.enforceState(master, 'I@sphinx:server', 'sphinx') |
| } |
| |
| //Configure Grafana |
| def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
| common.prettyPrint(pillar) |
| |
| def stacklight_vip |
| if(!pillar['return'].isEmpty()) { |
| stacklight_vip = pillar['return'][0].values()[0] |
| } else { |
| common.errorMsg('[ERROR] Stacklight VIP address could not be retrieved') |
| } |
| |
| common.infoMsg("Waiting for service on http://${stacklight_vip}:15013/ to start") |
| sleep(120) |
| salt.enforceState(master, 'I@grafana:client', 'grafana.client') |
| } |
| |
| def installStacklightv1Control(master) { |
| def salt = new com.mirantis.mk.Salt() |
| |
| // infra install |
| // Install the StackLight backends |
| salt.enforceState(master, '*01* and I@elasticsearch:server', 'elasticsearch.server') |
| salt.enforceState(master, 'I@elasticsearch:server', 'elasticsearch.server') |
| |
| salt.enforceState(master, '*01* and I@influxdb:server', 'influxdb') |
| salt.enforceState(master, 'I@influxdb:server', 'influxdb') |
| |
| salt.enforceState(master, '*01* and I@kibana:server', 'kibana.server') |
| salt.enforceState(master, 'I@kibana:server', 'kibana.server') |
| |
| salt.enforceState(master, '*01* and I@grafana:server','grafana.server') |
| salt.enforceState(master, 'I@grafana:server','grafana.server') |
| |
| def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| def alarming_service = alarming_service_pillar['return'][0].values()[0] |
| |
| switch (alarming_service) { |
| case 'sensu': |
| // Update Sensu |
| salt.enforceState(master, 'I@sensu:server and I@rabbitmq:server', 'rabbitmq') |
| salt.enforceState(master, 'I@redis:cluster:role:master', 'redis') |
| salt.enforceState(master, 'I@redis:server', 'redis') |
| salt.enforceState(master, 'I@sensu:server', 'sensu') |
| default: |
| // Update Nagios |
| salt.enforceState(master, 'I@nagios:server', 'nagios.server') |
| // Stop the Nagios service because the package starts it by default and it will |
| // started later only on the node holding the VIP address |
| salt.runSaltProcessStep(master, 'I@nagios:server', 'service.stop', ['nagios3'], null, true) |
| } |
| |
| salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client.service') |
| salt.enforceState(master, 'I@kibana:client', 'kibana.client') |
| |
| sleep(10) |
| } |
| |
| def installStacklightv1Client(master) { |
| def salt = new com.mirantis.mk.Salt() |
| def common = new com.mirantis.mk.Common() |
| |
| salt.cmdRun(master, 'I@elasticsearch:client', 'salt-call state.sls elasticsearch.client') |
| // salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client', true) |
| salt.cmdRun(master, 'I@kibana:client', 'salt-call state.sls kibana.client') |
| // salt.enforceState(master, 'I@kibana:client', 'kibana.client', true) |
| |
| // Install collectd, heka and sensu services on the nodes, this will also |
| // generate the metadata that goes into the grains and eventually into Salt Mine |
| salt.enforceState(master, '*', 'collectd') |
| salt.enforceState(master, '*', 'salt.minion') |
| salt.enforceState(master, '*', 'heka') |
| |
| // Gather the Grafana metadata as grains |
| salt.enforceState(master, 'I@grafana:collector', 'grafana.collector', true) |
| |
| // Update Salt Mine |
| salt.enforceState(master, '*', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, '*', 'saltutil.refresh_modules') |
| salt.runSaltProcessStep(master, '*', 'mine.update') |
| |
| sleep(5) |
| |
| // Update Heka |
| salt.enforceState(master, 'I@heka:aggregator:enabled:True or I@heka:remote_collector:enabled:True', 'heka') |
| |
| // Update collectd |
| salt.enforceState(master, 'I@collectd:remote_client:enabled:True', 'collectd') |
| |
| def alarming_service_pillar = salt.getPillar(master, 'mon*01*', '_param:alarming_service') |
| def alarming_service = alarming_service_pillar['return'][0].values()[0] |
| |
| switch (alarming_service) { |
| case 'sensu': |
| // Update Sensu |
| // TODO for stacklight team, should be fixed in model |
| salt.enforceState(master, 'I@sensu:client', 'sensu') |
| default: |
| break |
| // Default is nagios, and was enforced in installStacklightControl() |
| } |
| |
| salt.cmdRun(master, 'I@grafana:client and *01*', 'salt-call state.sls grafana.client') |
| // salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client', true) |
| |
| // Finalize the configuration of Grafana (add the dashboards...) |
| salt.enforceState(master, 'I@grafana:client and *01*', 'grafana.client') |
| salt.enforceState(master, 'I@grafana:client and *02*', 'grafana.client') |
| salt.enforceState(master, 'I@grafana:client and *03*', 'grafana.client') |
| // nw salt -C 'I@grafana:client' --async service.restart salt-minion; sleep 10 |
| |
| // Get the StackLight monitoring VIP addres |
| //vip=$(salt-call pillar.data _param:stacklight_monitor_address --out key|grep _param: |awk '{print $2}') |
| //vip=${vip:=172.16.10.253} |
| def pillar = salt.getPillar(master, 'ctl01*', '_param:stacklight_monitor_address') |
| common.prettyPrint(pillar) |
| def stacklight_vip = pillar['return'][0].values()[0] |
| |
| if (stacklight_vip) { |
| // (re)Start manually the services that are bound to the monitoring VIP |
| common.infoMsg("restart services on node with IP: ${stacklight_vip}") |
| salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collectd']) |
| salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['remote_collector']) |
| salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['aggregator']) |
| salt.runSaltProcessStep(master, "G@ipv4:${stacklight_vip}", 'service.restart', ['nagios3']) |
| } else { |
| throw new Exception("Missing stacklight_vip") |
| } |
| } |
| |
| // |
| // backups |
| // |
| |
| def installBackup(master, component='common') { |
| def salt = new com.mirantis.mk.Salt() |
| if (component == 'common') { |
| // Install Backupninja |
| if (salt.testTarget(master, 'I@backupninja:client')) { |
| salt.enforceState(master, 'I@backupninja:client', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, 'I@backupninja:client', 'saltutil.sync_grains') |
| salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.flush') |
| salt.runSaltProcessStep(master, 'I@backupninja:client', 'mine.update') |
| salt.enforceState(master, 'I@backupninja:client', 'backupninja') |
| } |
| if (salt.testTarget(master, 'I@backupninja:server')) { |
| salt.enforceState(master, 'I@backupninja:server', 'salt.minion.grains') |
| salt.enforceState(master, 'I@backupninja:server', 'backupninja') |
| } |
| } else if (component == 'mysql') { |
| // Install Xtrabackup |
| if (salt.testTarget(master, 'I@xtrabackup:client')) { |
| salt.enforceState(master, 'I@xtrabackup:client', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'saltutil.sync_grains') |
| salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.flush') |
| salt.runSaltProcessStep(master, 'I@xtrabackup:client', 'mine.update') |
| salt.enforceState(master, 'I@xtrabackup:client', 'xtrabackup') |
| } |
| if (salt.testTarget(master, 'I@xtrabackup:server')) { |
| salt.enforceState(master, 'I@xtrabackup:server', 'xtrabackup') |
| } |
| } else if (component == 'contrail') { |
| |
| // Install Cassandra backup |
| if (salt.testTarget(master, 'I@cassandra:backup:client')) { |
| salt.enforceState(master, 'I@cassandra:backup:client', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'saltutil.sync_grains') |
| salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.flush') |
| salt.runSaltProcessStep(master, 'I@cassandra:backup:client', 'mine.update') |
| salt.enforceState(master, 'I@cassandra:backup:client', 'cassandra.backup') |
| } |
| if (salt.testTarget(master, 'I@cassandra:backup:server')) { |
| salt.enforceState(master, 'I@cassandra:backup:server', 'cassandra.backup') |
| } |
| // Install Zookeeper backup |
| if (salt.testTarget(master, 'I@zookeeper:backup:client')) { |
| salt.enforceState(master, 'I@zookeeper:backup:client', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'saltutil.sync_grains') |
| salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.flush') |
| salt.runSaltProcessStep(master, 'I@zookeeper:backup:client', 'mine.update') |
| salt.enforceState(master, 'I@zookeeper:backup:client', 'zookeeper.backup') |
| } |
| if (salt.testTarget(master, 'I@zookeeper:backup:server')) { |
| salt.enforceState(master, 'I@zookeeper:backup:server', 'zookeeper.backup') |
| } |
| } else if (component == 'ceph') { |
| // Install Ceph backup |
| if (salt.testTarget(master, 'I@ceph:backup:client')) { |
| salt.enforceState(master, 'I@ceph:backup:client', 'salt.minion.grains') |
| salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'saltutil.sync_grains') |
| salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.flush') |
| salt.runSaltProcessStep(master, 'I@ceph:backup:client', 'mine.update') |
| salt.enforceState(master, 'I@ceph:backup:client', 'ceph.backup') |
| } |
| if (salt.testTarget(master, 'I@ceph:backup:server')) { |
| salt.enforceState(master, 'I@ceph:backup:server', 'ceph.backup') |
| } |
| } |
| |
| } |
| |
| // |
| // Ceph |
| // |
| |
| def installCephMon(master, target='I@ceph:mon') { |
| def salt = new com.mirantis.mk.Salt() |
| |
| salt.enforceState(master, 'I@ceph:common', 'salt.minion.grains') |
| |
| // generate keyrings |
| if (salt.testTarget(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin')) { |
| salt.enforceState(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'ceph.mon') |
| salt.runSaltProcessStep(master, 'I@ceph:mon', 'saltutil.sync_grains') |
| salt.runSaltProcessStep(master, 'I@ceph:mon:keyring:mon or I@ceph:common:keyring:admin', 'mine.update') |
| sleep(5) |
| } |
| // install Ceph Mons |
| salt.enforceState(master, target, 'ceph.mon') |
| if (salt.testTarget(master, 'I@ceph:mgr')) { |
| salt.enforceState(master, 'I@ceph:mgr', 'ceph.mgr') |
| } |
| } |
| |
| def installCephOsd(master, target='I@ceph:osd', setup=true) { |
| def salt = new com.mirantis.mk.Salt() |
| |
| // install Ceph OSDs |
| salt.enforceState(master, target, 'ceph.osd') |
| salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains') |
| salt.enforceState(master, target, 'ceph.osd.custom') |
| salt.runSaltProcessStep(master, 'I@ceph:osd', 'saltutil.sync_grains') |
| salt.runSaltProcessStep(master, 'I@ceph:osd', 'mine.update') |
| installBackup(master, 'ceph') |
| |
| // setup pools, keyrings and maybe crush |
| if (salt.testTarget(master, 'I@ceph:setup') && setup) { |
| sleep(5) |
| salt.enforceState(master, 'I@ceph:setup', 'ceph.setup') |
| } |
| } |
| |
| def installCephClient(master) { |
| def salt = new com.mirantis.mk.Salt() |
| |
| // install Ceph Radosgw |
| if (salt.testTarget(master, 'I@ceph:radosgw')) { |
| salt.runSaltProcessStep(master, 'I@ceph:radosgw', 'saltutil.sync_grains') |
| salt.enforceState(master, 'I@ceph:radosgw', 'ceph.radosgw') |
| } |
| // setup Keystone service and endpoints for swift or / and S3 |
| if (salt.testTarget(master, 'I@keystone:client')) { |
| salt.enforceState(master, 'I@keystone:client', 'keystone.client') |
| } |
| } |
| |
| def connectCeph(master) { |
| def salt = new com.mirantis.mk.Salt() |
| |
| // connect Ceph to the env |
| if (salt.testTarget(master, 'I@ceph:common and I@glance:server')) { |
| salt.enforceState(master, 'I@ceph:common and I@glance:server', ['ceph.common', 'ceph.setup.keyring', 'glance']) |
| salt.runSaltProcessStep(master, 'I@ceph:common and I@glance:server', 'service.restart', ['glance-api']) |
| } |
| if (salt.testTarget(master, 'I@ceph:common and I@cinder:controller')) { |
| salt.enforceState(master, 'I@ceph:common and I@cinder:controller', ['ceph.common', 'ceph.setup.keyring', 'cinder']) |
| salt.runSaltProcessStep(master, 'I@ceph:common and I@cinder:controller', 'service.restart', ['cinder-volume']) |
| } |
| if (salt.testTarget(master, 'I@ceph:common and I@nova:compute')) { |
| salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['ceph.common', 'ceph.setup.keyring']) |
| salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'saltutil.sync_grains') |
| salt.enforceState(master, 'I@ceph:common and I@nova:compute', ['nova']) |
| salt.runSaltProcessStep(master, 'I@ceph:common and I@nova:compute', 'service.restart', ['nova-compute']) |
| } |
| } |
| |
| def installOssInfra(master) { |
| def common = new com.mirantis.mk.Common() |
| def salt = new com.mirantis.mk.Salt() |
| |
| if (!common.checkContains('STACK_INSTALL', 'k8s') || !common.checkContains('STACK_INSTALL', 'openstack')) { |
| def orchestrate = new com.mirantis.mk.Orchestrate() |
| orchestrate.installInfra(master) |
| } |
| |
| if (salt.testTarget(master, 'I@devops_portal:config')) { |
| salt.enforceState(master, 'I@devops_portal:config', 'devops_portal.config') |
| salt.enforceState(master, 'I@rundeck:client', ['linux.system.user', 'openssh']) |
| salt.enforceState(master, 'I@rundeck:server', 'rundeck.server') |
| } |
| } |
| |
| def installOss(master) { |
| def common = new com.mirantis.mk.Common() |
| def salt = new com.mirantis.mk.Salt() |
| |
| //Get oss VIP address |
| def pillar = salt.getPillar(master, 'cfg01*', '_param:stacklight_monitor_address') |
| common.prettyPrint(pillar) |
| |
| def oss_vip |
| if(!pillar['return'].isEmpty()) { |
| oss_vip = pillar['return'][0].values()[0] |
| } else { |
| common.errorMsg('[ERROR] Oss VIP address could not be retrieved') |
| } |
| |
| // Postgres client - initialize OSS services databases |
| timeout(120){ |
| common.infoMsg("Waiting for postgresql database to come up..") |
| 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') |
| } |
| // XXX: first run usually fails on some inserts, but we need to create databases at first |
| salt.enforceState(master, 'I@postgresql:client', 'postgresql.client', true, false) |
| |
| // Setup postgres database with integration between |
| // Pushkin notification service and Security Monkey security audit service |
| timeout(10) { |
| common.infoMsg("Waiting for Pushkin to come up..") |
| salt.cmdRun(master, 'I@postgresql:client', "while true; do curl -sf ${oss_vip}:8887/apps >/dev/null && break; done") |
| } |
| salt.enforceState(master, 'I@postgresql:client', 'postgresql.client') |
| |
| // Rundeck |
| timeout(10) { |
| common.infoMsg("Waiting for Rundeck to come up..") |
| salt.cmdRun(master, 'I@rundeck:client', "while true; do curl -sf ${oss_vip}:4440 >/dev/null && break; done") |
| } |
| salt.enforceState(master, 'I@rundeck:client', 'rundeck.client') |
| |
| // Elasticsearch |
| pillar = salt.getPillar(master, 'I@elasticsearch:client', 'elasticsearch:client:server:host') |
| def elasticsearch_vip |
| if(!pillar['return'].isEmpty()) { |
| elasticsearch_vip = pillar['return'][0].values()[0] |
| } else { |
| common.errorMsg('[ERROR] Elasticsearch VIP address could not be retrieved') |
| } |
| |
| timeout(10) { |
| common.infoMsg('Waiting for Elasticsearch to come up..') |
| salt.cmdRun(master, 'I@elasticsearch:client', "while true; do curl -sf ${elasticsearch_vip}:9200 >/dev/null && break; done") |
| } |
| salt.enforceState(master, 'I@elasticsearch:client', 'elasticsearch.client') |
| } |