Replace testTarget-enforceState with enforceStateWithTest
Change-Id: I7b70fbfc773f96e198e3d51ecb05c1dd4ba76925
diff --git a/src/com/mirantis/mk/Orchestrate.groovy b/src/com/mirantis/mk/Orchestrate.groovy
index dd9c9ba..3d38eea 100644
--- a/src/com/mirantis/mk/Orchestrate.groovy
+++ b/src/com/mirantis/mk/Orchestrate.groovy
@@ -61,24 +61,16 @@
salt.enforceState(master, "* ${extra_tgt}", ['linux.network.host'])
// Install and configure iptables
- if (salt.testTarget(master, "I@iptables:service ${extra_tgt}")) {
- salt.enforceState(master, "I@iptables:service ${extra_tgt}", 'iptables')
- }
+ salt.enforceStateWithTest(master, "I@iptables:service ${extra_tgt}", 'iptables')
// Install and configure logrotate
- if (salt.testTarget(master, "I@logrotate:server ${extra_tgt}")) {
- salt.enforceState(master, "I@logrotate:server ${extra_tgt}", 'logrotate')
- }
+ salt.enforceStateWithTest(master, "I@logrotate:server ${extra_tgt}", 'logrotate')
// Install and configure auditd
- if (salt.testTarget(master, "I@auditd:service ${extra_tgt}")) {
- salt.enforceState(master, "I@auditd:service ${extra_tgt}", 'auditd')
- }
+ salt.enforceStateWithTest(master, "I@auditd:service ${extra_tgt}", 'auditd')
// Install and configure openscap
- if (salt.testTarget(master, "I@openscap:service ${extra_tgt}")) {
- salt.enforceState(master, "I@openscap:service ${extra_tgt}", 'openscap')
- }
+ salt.enforceStateWithTest(master, "I@openscap:service ${extra_tgt}", 'openscap')
}
def installFoundationInfraOnTarget(master, target, staticMgmtNet=false, extra_tgt = '') {
@@ -186,9 +178,7 @@
}
// Ensure glusterfs clusters is ready
- if (salt.testTarget(master, "I@glusterfs:client ${extra_tgt}")) {
- salt.enforceState(master, "I@glusterfs:client ${extra_tgt}", 'glusterfs.client', true, true, null, false, -1, 2)
- }
+ salt.enforceStateWithTest(master, "I@glusterfs:client ${extra_tgt}", 'glusterfs.client', true, true, null, false, -1, 2)
// Install galera
if (salt.testTarget(master, "I@galera:master ${extra_tgt}") || salt.testTarget(master, "I@galera:slave ${extra_tgt}")) {
@@ -199,11 +189,9 @@
salt.runSaltProcessStep(master, "I@galera:master ${extra_tgt}", 'mysql.status')
salt.runSaltProcessStep(master, "I@galera:slave ${extra_tgt}", 'mysql.status')
// If galera is not enabled check if we need to install mysql:server
- } else if (salt.testTarget(master, "I@mysql:server ${extra_tgt}")){
- salt.enforceState(master, "I@mysql:server ${extra_tgt}", 'mysql.server')
- if (salt.testTarget(master, "I@mysql:client ${extra_tgt}")){
- salt.enforceState(master, "I@mysql:client ${extra_tgt}", 'mysql.client')
- }
+ } else {
+ salt.enforceStateWithTest(master, "I@mysql:server ${extra_tgt}", 'mysql.server')
+ salt.enforceStateWithTest(master, "I@mysql:client ${extra_tgt}", 'mysql.client')
}
installBackup(master, 'mysql', extra_tgt)
@@ -238,9 +226,7 @@
}
// Install memcached
- if (salt.testTarget(master, "I@memcached:server ${extra_tgt}")) {
- salt.enforceState(master, "I@memcached:server ${extra_tgt}", 'memcached')
- }
+ salt.enforceStateWithTest(master, "I@memcached:server ${extra_tgt}", 'memcached')
// Install etcd
if (salt.testTarget(master, "I@etcd:server ${extra_tgt}")) {
@@ -252,9 +238,7 @@
// Install redis
if (salt.testTarget(master, "I@redis:server ${extra_tgt}")) {
- if (salt.testTarget(master, "I@redis:cluster:role:master ${extra_tgt}")) {
- salt.enforceState(master, "I@redis:cluster:role:master ${extra_tgt}", 'redis')
- }
+ salt.enforceStateWithTest(master, "I@redis:cluster:role:master ${extra_tgt}", 'redis')
salt.enforceState(master, "I@redis:server ${extra_tgt}", 'redis')
}
@@ -282,17 +266,11 @@
def first_target
// Install horizon dashboard
- if (salt.testTarget(master, "I@horizon:server ${extra_tgt}")) {
- salt.enforceState(master, "I@horizon:server ${extra_tgt}", 'horizon')
- }
+ salt.enforceStateWithTest(master, "I@horizon:server ${extra_tgt}", 'horizon')
// Install sphinx server
- if (salt.testTarget(master, "I@sphinx:server ${extra_tgt}")) {
- salt.enforceState(master, "I@sphinx:server ${extra_tgt}", 'sphinx')
- }
- if (salt.testTarget(master, "I@nginx:server ${extra_tgt}")) {
- salt.enforceState(master, "I@nginx:server ${extra_tgt}", 'salt.minion')
- salt.enforceState(master, "I@nginx:server ${extra_tgt}", 'nginx')
- }
+ salt.enforceStateWithTest(master, "I@sphinx:server ${extra_tgt}", 'sphinx')
+ salt.enforceStateWithTest(master, "I@nginx:server ${extra_tgt}", 'salt.minion')
+ salt.enforceStateWithTest(master, "I@nginx:server ${extra_tgt}", 'nginx')
// setup keystone service
if (salt.testTarget(master, "I@keystone:server ${extra_tgt}")) {
@@ -317,11 +295,8 @@
}
// Install glance
- if (salt.testTarget(master, "I@glance:server ${extra_tgt}")) {
- //runSaltProcessStep(master, 'I@glance:server', 'state.sls', ['glance.server'], 1)
- salt.enforceState(master, "I@glance:server:role:primary ${extra_tgt}", 'glance.server')
- salt.enforceState(master, "I@glance:server ${extra_tgt}", 'glance.server')
- }
+ salt.enforceStateWithTest(master, "I@glance:server:role:primary ${extra_tgt}", 'glance.server', "I@glance:server ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@glance:server ${extra_tgt}", 'glance.server')
// Check glance service
if (salt.testTarget(master, "I@glance:server ${extra_tgt}")) {
@@ -331,60 +306,48 @@
}
// Create glance resources
- if (salt.testTarget(master, "I@glance:client ${extra_tgt}")) {
- salt.enforceState(master, "I@glance:client ${extra_tgt}", 'glance.client')
- }
+ salt.enforceStateWithTest(master, "I@glance:client ${extra_tgt}", 'glance.client')
// Install and check nova service
- if (salt.testTarget(master, "I@nova:controller ${extra_tgt}")) {
- // run on first node first
- salt.enforceState(master, "I@nova:controller:role:primary ${extra_tgt}", 'nova.controller')
- salt.enforceState(master, "I@nova:controller ${extra_tgt}", 'nova.controller')
- if (salt.testTarget(master, "I@keystone:server ${extra_tgt}")) {
- common.retry(3,5){
- salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; nova service-list')
- }
+ // run on first node first
+ salt.enforceStateWithTest(master, "I@nova:controller:role:primary ${extra_tgt}", 'nova.controller', "I@nova:controller ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@nova:controller ${extra_tgt}", 'nova.controller')
+ if (salt.testTarget(master, "I@keystone:server and I@nova:controller ${extra_tgt}")) {
+ common.retry(3,5){
+ salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; nova service-list')
}
}
+
// Create nova resources
- if (salt.testTarget(master, "I@nova:client ${extra_tgt}")) {
- salt.enforceState(master, "I@nova:client ${extra_tgt}", 'nova.client')
- }
+ salt.enforceStateWithTest(master, "I@nova:client ${extra_tgt}", 'nova.client')
// Install and check cinder service
- if (salt.testTarget(master, "I@cinder:controller ${extra_tgt}")) {
- // run on first node first
- salt.enforceState(master, "I@cinder:controller:role:primary ${extra_tgt}", 'cinder')
- salt.enforceState(master, "I@cinder:controller ${extra_tgt}", 'cinder')
- if (salt.testTarget(master, "I@keystone:server ${extra_tgt}")) {
- common.retry(3,5){
- salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; cinder list')
- }
+ // run on first node first
+ salt.enforceStateWithTest(master, "I@cinder:controller:role:primary ${extra_tgt}", 'cinder', "I@cinder:controller ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@cinder:controller ${extra_tgt}", 'cinder')
+ if (salt.testTarget(master, "I@keystone:server and I@cinder:controller ${extra_tgt}")) {
+ common.retry(3,5){
+ salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; cinder list')
}
}
// Install neutron service
- if (salt.testTarget(master, "I@neutron:server ${extra_tgt}")) {
- // run on first node first
- salt.enforceState(master, "I@neutron:server:role:primary ${extra_tgt}", 'neutron.server')
- salt.enforceState(master, "I@neutron:server ${extra_tgt}", 'neutron.server')
- if (salt.testTarget(master, "I@keystone:server ${extra_tgt}")) {
- common.retry(3,5){
- salt.cmdRun(master, "I@keystone:server ${extra_tgt}",'. /root/keystonercv3; neutron agent-list')
- }
+ // run on first node first
+ salt.enforceStateWithTest(master, "I@neutron:server:role:primary ${extra_tgt}", 'neutron.server', "I@neutron:server ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@neutron:server ${extra_tgt}", 'neutron.server')
+ if (salt.testTarget(master, "I@keystone:server and I@neutron:server ${extra_tgt}")) {
+ common.retry(3,5){
+ salt.cmdRun(master, "I@keystone:server ${extra_tgt}",'. /root/keystonercv3; neutron agent-list')
}
}
// Install heat service
- if (salt.testTarget(master, "I@heat:server ${extra_tgt}")) {
- // run on first node first
- salt.enforceState(master, "I@heat:server:role:primary ${extra_tgt}", 'heat')
- salt.enforceState(master, "I@heat:server ${extra_tgt}", 'heat')
- if (salt.testTarget(master, "I@keystone:server ${extra_tgt}")) {
- common.retry(3,5){
- salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; openstack orchestration resource type list')
- }
+ salt.enforceStateWithTest(master, "I@heat:server:role:primary ${extra_tgt}", 'heat', "I@heat:server ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@heat:server ${extra_tgt}", 'heat')
+ if (salt.testTarget(master, "I@keystone:server and I@heat:server ${extra_tgt}")) {
+ common.retry(3,5){
+ salt.cmdRun(master, "I@keystone:server ${extra_tgt}", '. /root/keystonercv3; openstack orchestration resource type list')
}
}
@@ -394,19 +357,13 @@
}
// Install ironic service
- if (salt.testTarget(master, "I@ironic:api ${extra_tgt}")) {
- salt.enforceState(master, "I@ironic:api:role:primary ${extra_tgt}", 'ironic.api')
- salt.enforceState(master, "I@ironic:api ${extra_tgt}", 'ironic.api')
- }
+ salt.enforceStateWithTest(master, "I@ironic:api:role:primary ${extra_tgt}", 'ironic.api', "I@ironic:api ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@ironic:api ${extra_tgt}", 'ironic.api')
// Install manila service
- if (salt.testTarget(master, "I@manila:api ${extra_tgt}")) {
- salt.enforceState(master, "I@manila:api:role:primary ${extra_tgt}", 'manila.api')
- salt.enforceState(master, "I@manila:api ${extra_tgt}", 'manila.api')
- }
- if (salt.testTarget(master, "I@manila:scheduler ${extra_tgt}")) {
- salt.enforceState(master, "I@manila:scheduler ${extra_tgt}", 'manila.scheduler')
- }
+ salt.enforceStateWithTest(master, "I@manila:api:role:primary ${extra_tgt}", 'manila.api', "I@manila:api ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@manila:api ${extra_tgt}", 'manila.api')
+ salt.enforceStateWithTest(master, "I@manila:scheduler ${extra_tgt}", 'manila.scheduler')
// Install designate services
if (salt.testTarget(master, "I@designate:server:enabled ${extra_tgt}")) {
@@ -415,32 +372,23 @@
}
// Install octavia api service
- if (salt.testTarget(master, "I@octavia:api ${extra_tgt}")) {
- salt.enforceState(master, "I@octavia:api:role:primary ${extra_tgt}", 'octavia.api')
- salt.enforceState(master, "I@octavia:api ${extra_tgt}", 'octavia.api')
- }
+ salt.enforceStateWithTest(master, "I@octavia:api:role:primary ${extra_tgt}", 'octavia.api', "I@octavia:api ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@octavia:api ${extra_tgt}", 'octavia.api')
// Install DogTag server service
- if (salt.testTarget(master, "I@dogtag:server ${extra_tgt}")) {
- salt.enforceState(master, "I@dogtag:server:role:master ${extra_tgt}", 'dogtag.server')
- salt.enforceState(master, "I@dogtag:server ${extra_tgt}", 'dogtag.server')
- }
+ salt.enforceStateWithTest(master, "I@dogtag:server:role:master ${extra_tgt}", 'dogtag.server', "I@dogtag:server ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@dogtag:server ${extra_tgt}", 'dogtag.server')
// Install barbican server service
- if (salt.testTarget(master, "I@barbican:server ${extra_tgt}")) {
- salt.enforceState(master, "I@barbican:server:role:primary ${extra_tgt}", 'barbican.server')
- salt.enforceState(master, "I@barbican:server ${extra_tgt}", 'barbican.server')
- }
+ salt.enforceStateWithTest(master, "I@barbican:server:role:primary ${extra_tgt}", 'barbican.server', "I@barbican:server ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@barbican:server ${extra_tgt}", 'barbican.server')
+
// Install barbican client
- if (salt.testTarget(master, "I@barbican:client ${extra_tgt}")) {
- salt.enforceState(master, "I@barbican:client ${extra_tgt}", 'barbican.client')
- }
+ salt.enforceStateWithTest(master, "I@barbican:client ${extra_tgt}", 'barbican.client')
// Install gnocchi server
- if (salt.testTarget(master, "I@gnocchi:server ${extra_tgt}")) {
- salt.enforceState(master, "I@gnocchi:server:role:primary ${extra_tgt}", 'gnocchi.server')
- salt.enforceState(master, "I@gnocchi:server ${extra_tgt}", 'gnocchi.server')
- }
+ salt.enforceStateWithTest(master, "I@gnocchi:server:role:primary ${extra_tgt}", 'gnocchi.server', "I@gnocchi:server ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@gnocchi:server ${extra_tgt}", 'gnocchi.server')
// Apply gnocchi client state to create gnocchi archive policies, due to possible
// races, apply on the first node initially
@@ -465,10 +413,8 @@
}
// Install ceilometer server
- if (salt.testTarget(master, "I@ceilometer:server ${extra_tgt}")) {
- salt.enforceState(master, "I@ceilometer:server:role:primary ${extra_tgt}", 'ceilometer')
- salt.enforceState(master, "I@ceilometer:server ${extra_tgt}", 'ceilometer')
- }
+ salt.enforceStateWithTest(master, "I@ceilometer:server:role:primary ${extra_tgt}", 'ceilometer', "I@ceilometer:server ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@ceilometer:server ${extra_tgt}", 'ceilometer')
// Install aodh server
if (salt.testTarget(master, "I@aodh:server ${extra_tgt}")) {
@@ -482,39 +428,24 @@
def installIronicConductor(master, extra_tgt = ''){
def salt = new com.mirantis.mk.Salt()
- if (salt.testTarget(master, "I@ironic:conductor ${extra_tgt}")) {
- salt.enforceState(master, "I@ironic:conductor ${extra_tgt}", 'ironic.conductor')
- salt.enforceState(master, "I@ironic:conductor ${extra_tgt}", 'apache')
- }
- if (salt.testTarget(master, "I@tftpd_hpa:server ${extra_tgt}")) {
- salt.enforceState(master, "I@tftpd_hpa:server ${extra_tgt}", 'tftpd_hpa')
- }
+ salt.enforceStateWithTest(master, "I@ironic:conductor ${extra_tgt}", 'ironic.conductor')
+ salt.enforceStateWithTest(master, "I@ironic:conductor ${extra_tgt}", 'apache')
+ salt.enforceStateWithTest(master, "I@tftpd_hpa:server ${extra_tgt}", 'tftpd_hpa')
if (salt.testTarget(master, "I@nova:compute ${extra_tgt}")) {
salt.runSaltProcessStep(master, "I@nova:compute ${extra_tgt}", 'service.restart', ['nova-compute'])
}
- if (salt.testTarget(master, "I@baremetal_simulator:enabled ${extra_tgt}")) {
- salt.enforceState(master, "I@baremetal_simulator:enabled ${extra_tgt}", 'baremetal_simulator')
- }
- if (salt.testTarget(master, "I@ironic:client ${extra_tgt}")) {
- salt.enforceState(master, "I@ironic:client ${extra_tgt}", 'ironic.client')
- }
+ salt.enforceStateWithTest(master, "I@baremetal_simulator:enabled ${extra_tgt}", 'baremetal_simulator')
+ salt.enforceStateWithTest(master, "I@ironic:client ${extra_tgt}", 'ironic.client')
}
def installManilaShare(master, extra_tgt = ''){
def salt = new com.mirantis.mk.Salt()
- if (salt.testTarget(master, "I@manila:share ${extra_tgt}")) {
- salt.enforceState(master, "I@manila:share ${extra_tgt}", 'manila.share')
- }
- if (salt.testTarget(master, "I@manila:data ${extra_tgt}")) {
- salt.enforceState(master, "I@manila:data ${extra_tgt}", 'manila.data')
- }
-
- if (salt.testTarget(master, "I@manila:client ${extra_tgt}")) {
- salt.enforceState(master, "I@manila:client ${extra_tgt}", 'manila.client')
- }
+ salt.enforceStateWithTest(master, "I@manila:share ${extra_tgt}", 'manila.share')
+ salt.enforceStateWithTest(master, "I@manila:data ${extra_tgt}", 'manila.data')
+ salt.enforceStateWithTest(master, "I@manila:client ${extra_tgt}", 'manila.client')
}
@@ -524,16 +455,12 @@
//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 ${extra_tgt}")) {
- salt.enforceState(master, "I@neutron:gateway ${extra_tgt}", 'neutron')
- }
+ salt.enforceStateWithTest(master, "I@neutron:gateway ${extra_tgt}", '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 ${extra_tgt}")) {
- salt.enforceState(master, "I@neutron:client ${extra_tgt}", 'neutron.client')
- }
+ salt.enforceStateWithTest(master, "I@neutron:client ${extra_tgt}", 'neutron.client')
salt.enforceHighstate(master, "I@neutron:gateway ${extra_tgt}")
@@ -594,9 +521,7 @@
}
// Run nova:controller to map cmp with cells
- if (salt.testTarget(master, "I@nova:controller ${extra_tgt}")) {
- salt.enforceState(master, "I@nova:controller:role:primary ${extra_tgt}", 'nova.controller')
- }
+ salt.enforceState(master, "I@nova:controller:role:primary ${extra_tgt}", 'nova.controller', "I@nova:controller ${extra_tgt}")
}
@@ -618,9 +543,7 @@
salt.enforceStateWithExclude(master, "${first_target} ${extra_tgt}", "opencontrail", "opencontrail.client")
salt.enforceStateWithExclude(master, "I@opencontrail:collector ${extra_tgt}", "opencontrail", "opencontrail.client")
- if (salt.testTarget(master, "I@docker:client and I@opencontrail:control ${extra_tgt}")) {
- salt.enforceState(master, "( I@opencontrail:control or I@opencontrail:collector ) ${extra_tgt}", 'docker.client')
- }
+ salt.enforceStateWithTest(master, "( I@opencontrail:control or I@opencontrail:collector ) ${extra_tgt}", 'docker.client', "I@docker:client and I@opencontrail:control ${extra_tgt}")
installBackup(master, 'contrail', extra_tgt)
}
@@ -643,10 +566,8 @@
}
sleep(300)
- if (salt.testTarget(master, "I@opencontrail:compute ${extra_tgt}")) {
- salt.enforceState(master, "I@opencontrail:compute ${extra_tgt}", 'opencontrail.client')
- salt.enforceState(master, "I@opencontrail:compute ${extra_tgt}", 'opencontrail')
- }
+ salt.enforceStateWithTest(master, "I@opencontrail:compute ${extra_tgt}", 'opencontrail.client')
+ salt.enforceStateWithTest(master, "I@opencontrail:compute ${extra_tgt}", 'opencontrail')
}
@@ -732,9 +653,7 @@
salt.enforceState(master, "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", 'kubernetes.pool')
// Install Tiller and all configured releases
- if (salt.testTarget(master, "I@helm:client ${extra_tgt}")) {
- salt.enforceState(master, "I@helm:client ${extra_tgt}", 'helm')
- }
+ salt.enforceStateWithTest(master, "I@helm:client ${extra_tgt}", 'helm')
salt.runSaltProcessStep(master, "I@kubernetes:pool and not I@kubernetes:master ${extra_tgt}", 'service.restart', ['kubelet'])
}
@@ -751,9 +670,7 @@
salt.runSaltProcessStep(master, "I@docker:swarm ${extra_tgt}", 'saltutil.refresh_modules')
sleep(5)
salt.enforceState(master, "I@docker:swarm:role:master ${extra_tgt}", 'docker.swarm')
- if (salt.testTarget(master, "I@docker:swarm:role:manager ${extra_tgt}")){
- salt.enforceState(master, "I@docker:swarm:role:manager ${extra_tgt}", 'docker.swarm')
- }
+ salt.enforceStateWithTest(master, "I@docker:swarm:role:manager ${extra_tgt}", 'docker.swarm')
sleep(10)
salt.cmdRun(master, "I@docker:swarm:role:master ${extra_tgt}", 'docker node ls')
}
@@ -832,13 +749,9 @@
salt.cmdRun(master, jenkins_compound, 'timeout ' + (wait_timeout*60+3) + ' /bin/sh -c -- ' + '"' + check_jenkins_cmd + '"')
}
- if (salt.testTarget(master, "I@openldap:client ${extra_tgt}")) {
- salt.enforceState(master, "I@openldap:client ${extra_tgt}", 'openldap', true, true, null, false, -1, 2)
- }
+ salt.enforceStateWithTest(master, "I@openldap:client ${extra_tgt}", 'openldap', "", true, true, null, false, -1, 2)
- if (salt.testTarget(master, "I@python:environment ${extra_tgt}")) {
- salt.enforceState(master, "I@python:environment ${extra_tgt}", 'python')
- }
+ salt.enforceStateWithTest(master, "I@python:environment ${extra_tgt}", 'python')
withEnv(['ASK_ON_ERROR=false']){
retry(2){
@@ -875,13 +788,9 @@
salt.enforceState(master, "I@haproxy:proxy ${extra_tgt}", 'haproxy')
salt.runSaltProcessStep(master, "I@haproxy:proxy ${extra_tgt}", 'service.status', ['haproxy'])
- if (salt.testTarget(master, "I@nginx:server ${extra_tgt}")) {
- salt.enforceState(master, "I@nginx:server ${extra_tgt}", 'nginx')
- }
+ salt.enforceStateWithTest(master, "I@nginx:server ${extra_tgt}", 'nginx')
- if (salt.testTarget(master, "I@glusterfs:client ${extra_tgt}")) {
- salt.enforceState(master, "I@glusterfs:client ${extra_tgt}", 'glusterfs.client', true, true, null, false, -1, 2)
- }
+ salt.enforceStateWithTest(master, "I@glusterfs:client ${extra_tgt}", 'glusterfs.client', "", true, true, null, false, -1, 2)
}
// Install MongoDB for Alerta
@@ -898,25 +807,20 @@
salt.enforceState(master, "( I@telegraf:agent or I@telegraf:remote_agent ) ${extra_tgt}", 'telegraf')
// Install Prometheus exporters
- if (salt.testTarget(master, "I@prometheus:exporters ${extra_tgt}")) {
- salt.enforceState(master, "I@prometheus:exporters ${extra_tgt}", 'prometheus')
- }
+ salt.enforceStateWithTest(master, "I@prometheus:exporters ${extra_tgt}", 'prometheus')
//Install Elasticsearch and Kibana
if (salt.testTarget(master, "I@elasticsearch:server:enabled:true ${extra_tgt}")) {
first_target = salt.getFirstMinion(master, "I@elasticsearch:server:enabled:true ${extra_tgt}")
salt.enforceState(master, "${first_target} ${extra_tgt}", 'elasticsearch.server')
}
- if (salt.testTarget(master, "I@elasticsearch:server:enabled:true ${extra_tgt}")) {
- salt.enforceState(master, "I@elasticsearch:server:enabled:true ${extra_tgt}", 'elasticsearch.server')
- }
+ salt.enforceStateWithTest(master, "I@elasticsearch:server:enabled:true ${extra_tgt}", 'elasticsearch.server')
if (salt.testTarget(master, "I@kibana:server:enabled:true ${extra_tgt}")) {
first_target = salt.getFirstMinion(master, "I@kibana:server:enabled:true ${extra_tgt}")
salt.enforceState(master, "${first_target} ${extra_tgt}", 'kibana.server')
}
- if (salt.testTarget(master, "I@kibana:server:enabled:true ${extra_tgt}")) {
- salt.enforceState(master, "I@kibana:server:enabled:true ${extra_tgt}", 'kibana.server')
- }
+ salt.enforceStateWithTest(master, "I@kibana:server:enabled:true ${extra_tgt}", 'kibana.server')
+
// Check ES health cluster status
def pillar = salt.getPillar(master, "I@elasticsearch:client ${extra_tgt}", 'elasticsearch:client:server:host')
def elasticsearch_vip
@@ -994,14 +898,10 @@
salt.runSaltProcessStep(master, "I@docker:swarm and I@prometheus:server ${extra_tgt}", 'dockerng.ps')
//Install Prometheus LTS
- if (salt.testTarget(master, "I@prometheus:relay ${extra_tgt}")) {
- salt.enforceState(master, "I@prometheus:relay ${extra_tgt}", 'prometheus')
- }
+ salt.enforceStateWithTest(master, "I@prometheus:relay ${extra_tgt}", 'prometheus')
// Install sphinx server
- if (salt.testTarget(master, "I@sphinx:server ${extra_tgt}")) {
- salt.enforceState(master, "I@sphinx:server ${extra_tgt}", 'sphinx')
- }
+ salt.enforceStateWithTest(master, "I@sphinx:server ${extra_tgt}", 'sphinx')
//Configure Grafana
pillar = salt.getPillar(master, "ctl01* ${extra_tgt}", '_param:stacklight_monitor_address')
@@ -1147,10 +1047,8 @@
salt.runSaltProcessStep(master, "I@backupninja:client ${extra_tgt}", 'mine.update')
salt.enforceState(master, "I@backupninja:client ${extra_tgt}", 'backupninja')
}
- if (salt.testTarget(master, "I@backupninja:server ${extra_tgt}")) {
- salt.enforceState(master, "I@backupninja:server ${extra_tgt}", 'salt.minion.grains')
- salt.enforceState(master, "I@backupninja:server ${extra_tgt}", 'backupninja')
- }
+ salt.enforceStateWithTest(master, "I@backupninja:server ${extra_tgt}", 'salt.minion.grains')
+ salt.enforceStateWithTest(master, "I@backupninja:server ${extra_tgt}", 'backupninja')
} else if (component == 'mysql') {
// Install Xtrabackup
if (salt.testTarget(master, "I@xtrabackup:client ${extra_tgt}")) {
@@ -1160,9 +1058,7 @@
salt.runSaltProcessStep(master, "I@xtrabackup:client ${extra_tgt}", 'mine.update')
salt.enforceState(master, "I@xtrabackup:client ${extra_tgt}", 'xtrabackup')
}
- if (salt.testTarget(master, "I@xtrabackup:server ${extra_tgt}")) {
- salt.enforceState(master, "I@xtrabackup:server ${extra_tgt}", 'xtrabackup')
- }
+ salt.enforceStateWithTest(master, "I@xtrabackup:server ${extra_tgt}", 'xtrabackup')
} else if (component == 'contrail') {
// Install Cassandra backup
@@ -1173,9 +1069,7 @@
salt.runSaltProcessStep(master, "I@cassandra:backup:client ${extra_tgt}", 'mine.update')
salt.enforceState(master, "I@cassandra:backup:client ${extra_tgt}", 'cassandra.backup')
}
- if (salt.testTarget(master, "I@cassandra:backup:server ${extra_tgt}")) {
- salt.enforceState(master, "I@cassandra:backup:server ${extra_tgt}", 'cassandra.backup')
- }
+ salt.enforceStateWithTest(master, "I@cassandra:backup:server ${extra_tgt}", 'cassandra.backup')
// Install Zookeeper backup
if (salt.testTarget(master, "I@zookeeper:backup:client ${extra_tgt}")) {
salt.enforceState(master, "I@zookeeper:backup:client ${extra_tgt}", 'salt.minion.grains')
@@ -1184,9 +1078,7 @@
salt.runSaltProcessStep(master, "I@zookeeper:backup:client ${extra_tgt}", 'mine.update')
salt.enforceState(master, "I@zookeeper:backup:client ${extra_tgt}", 'zookeeper.backup')
}
- if (salt.testTarget(master, "I@zookeeper:backup:server ${extra_tgt}")) {
- salt.enforceState(master, "I@zookeeper:backup:server ${extra_tgt}", 'zookeeper.backup')
- }
+ salt.enforceStateWithTest(master, "I@zookeeper:backup:server ${extra_tgt}", 'zookeeper.backup')
} else if (component == 'ceph') {
// Install Ceph backup
if (salt.testTarget(master, "I@ceph:backup:client ${extra_tgt}")) {
@@ -1196,9 +1088,7 @@
salt.runSaltProcessStep(master, "I@ceph:backup:client ${extra_tgt}", 'mine.update')
salt.enforceState(master, "I@ceph:backup:client ${extra_tgt}", 'ceph.backup')
}
- if (salt.testTarget(master, "I@ceph:backup:server ${extra_tgt}")) {
- salt.enforceState(master, "I@ceph:backup:server ${extra_tgt}", 'ceph.backup')
- }
+ salt.enforceStateWithTest(master, "I@ceph:backup:server ${extra_tgt}", 'ceph.backup')
}
}
@@ -1221,9 +1111,7 @@
}
// install Ceph Mons
salt.enforceState(master, target, 'ceph.mon')
- if (salt.testTarget(master, "I@ceph:mgr ${extra_tgt}")) {
- salt.enforceState(master, "I@ceph:mgr ${extra_tgt}", 'ceph.mgr')
- }
+ salt.enforceStateWithTest(master, "I@ceph:mgr ${extra_tgt}", 'ceph.mgr')
}
def installCephOsd(master, target="I@ceph:osd", setup=true, extra_tgt = '') {
@@ -1248,37 +1136,29 @@
def salt = new com.mirantis.mk.Salt()
// install Ceph Radosgw
- if (salt.testTarget(master, "I@ceph:radosgw ${extra_tgt}")) {
+ if (salt.testTarget(master, "I@ceph:radosgw ${extra_tgt} and I@node_role.openstack-control")) {
salt.runSaltProcessStep(master, "I@ceph:radosgw ${extra_tgt}", 'saltutil.sync_grains')
salt.enforceState(master, "I@ceph:radosgw ${extra_tgt}", 'ceph.radosgw')
}
// setup keyring for Openstack services
- if (salt.testTarget(master, "I@ceph:common and I@glance:server ${extra_tgt}")) {
- salt.enforceState(master, "I@ceph:common and I@glance:server ${extra_tgt}", ['ceph.common', 'ceph.setup.keyring'])
- }
+ salt.enforceStateWithTest(master, "I@ceph:common and I@glance:server ${extra_tgt}", ['ceph.common', 'ceph.setup.keyring'])
- if (salt.testTarget(master, "I@ceph:common and I@cinder:controller ${extra_tgt}")) {
- salt.enforceState(master, "I@ceph:common and I@cinder:controller ${extra_tgt}", ['ceph.common', 'ceph.setup.keyring'])
- }
+ salt.enforceStateWithTest(master, "I@ceph:common and I@cinder:controller ${extra_tgt}", ['ceph.common', 'ceph.setup.keyring'])
if (salt.testTarget(master, "I@ceph:common and I@nova:compute ${extra_tgt}")) {
salt.enforceState(master, "I@ceph:common and I@nova:compute ${extra_tgt}", ['ceph.common', 'ceph.setup.keyring'])
salt.runSaltProcessStep(master, "I@ceph:common and I@nova:compute ${extra_tgt}", 'saltutil.sync_grains')
}
- if (salt.testTarget(master, "I@ceph:common and I@gnocchi:server ${extra_tgt}")) {
- salt.enforceState(master, "I@ceph:common and I@gnocchi:server ${extra_tgt}", ['ceph.common', 'ceph.setup.keyring'])
- }
+ salt.enforceStateWithTest(master, "I@ceph:common and I@gnocchi:server ${extra_tgt}", ['ceph.common', 'ceph.setup.keyring'])
}
def connectCeph(master, extra_tgt = '') {
def salt = new com.mirantis.mk.Salt()
// setup Keystone service and endpoints for swift or / and S3
- if (salt.testTarget(master, "I@keystone:client ${extra_tgt}")) {
- salt.enforceState(master, "I@keystone:client ${extra_tgt}", 'keystone.client')
- }
+ salt.enforceStateWithTest(master, "I@keystone:client ${extra_tgt}", 'keystone.client')
// connect Ceph to the env
if (salt.testTarget(master, "I@ceph:common and I@glance:server ${extra_tgt}")) {
@@ -1303,11 +1183,9 @@
def common = new com.mirantis.mk.Common()
def salt = new com.mirantis.mk.Salt()
- if (salt.testTarget(master, "I@devops_portal:config ${extra_tgt}")) {
- salt.enforceState(master, "I@devops_portal:config ${extra_tgt}", 'devops_portal.config')
- salt.enforceState(master, "I@rundeck:client ${extra_tgt}", ['linux.system.user', 'openssh'])
- salt.enforceState(master, "I@rundeck:server ${extra_tgt}", 'rundeck.server')
- }
+ salt.enforceStateWithTest(master, "I@devops_portal:config ${extra_tgt}", 'devops_portal.config', )
+ salt.enforceStateWithTest(master, "I@rundeck:client ${extra_tgt}", ['linux.system.user', 'openssh'], "I@devops_portal:config ${extra_tgt}")
+ salt.enforceStateWithTest(master, "I@rundeck:server ${extra_tgt}", 'rundeck.server', "I@devops_portal:config ${extra_tgt}")
}
def installOss(master, extra_tgt = '') {
@@ -1390,4 +1268,4 @@
else {
common.infoMsg("No applications found for orchestration")
}
-}
+}
\ No newline at end of file