Optimize 'noservices' condition
diff --git a/cinder/controller.sls b/cinder/controller.sls
index 759c108..a00bd3f 100644
--- a/cinder/controller.sls
+++ b/cinder/controller.sls
@@ -55,28 +55,30 @@
- require:
- pkg: cinder_controller_packages
-{%- if not grains.get('noservices', False) %}
cinder_api_service:
service.running:
- name: apache2
- enable: true
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- watch:
- file: /etc/cinder/cinder.conf
- file: /etc/cinder/api-paste.ini
- file: /etc/apache2/conf-available/cinder-wsgi.conf
-{%- endif %}
{%- else %}
-{%- if not grains.get('noservices', False) %}
cinder_api_service:
service.running:
- name: cinder-api
- enable: true
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- watch:
- file: /etc/cinder/cinder.conf
- file: /etc/cinder/api-paste.ini
-{%- endif %}
{%- endif %}
@@ -92,12 +94,13 @@
{%- endif %}
-{%- if not grains.get('noservices', False) %}
-
cinder_controller_services:
service.running:
- names: {{ controller.services }}
- enable: true
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- watch:
- file: /etc/cinder/cinder.conf
- file: /etc/cinder/api-paste.ini
@@ -105,10 +108,14 @@
cinder_syncdb:
cmd.run:
- name: cinder-manage db sync
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- require:
- service: cinder_controller_services
{# new way #}
+{%- if not grains.get('noservices', False) %}
{%- for backend_name, backend in controller.get('backend', {}).iteritems() %}
diff --git a/cinder/volume.sls b/cinder/volume.sls
index b4bc0f8..ee5d9ea 100644
--- a/cinder/volume.sls
+++ b/cinder/volume.sls
@@ -15,10 +15,8 @@
- group: cinder
- require:
- pkg: cinder_volume_packages
- {%- if not grains.get('noservices', False) %}
- require_in:
- service: cinder_volume_services
- {%- endif %}
{%- if not pillar.cinder.get('controller', {}).get('enabled', False) %}
@@ -46,6 +44,9 @@
service.running:
- names: {{ volume.backup.services }}
- enable: true
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- watch:
- file: /etc/cinder/cinder.conf
- file: /etc/cinder/api-paste.ini
@@ -54,18 +55,17 @@
{%- endif %}
-{%- if not grains.get('noservices', False) %}
-
cinder_volume_services:
service.running:
- names: {{ volume.services }}
- enable: true
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- watch:
- file: /etc/cinder/cinder.conf
- file: /etc/cinder/api-paste.ini
-{%- endif %}
-
{# new way #}
{%- if volume.backend is defined %}
@@ -90,22 +90,20 @@
- require:
- pkg: cinder_iscsi_packages_{{ loop.index }}
-{%- if not grains.get('noservices', False) %}
-
cinder_scsi_service:
service.running:
- names:
- iscsitarget
- open-iscsi
- enable: true
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- watch:
- file: /etc/default/iscsitarget
{%- endif %}
-
-{%- endif %}
-
{%- if backend.engine == 'hitachi_vsp' %}
{%- if grains.os_family == 'Debian' and volume.version == 'juno' %}
@@ -178,21 +176,20 @@
- require:
- pkg: cinder_iscsi_packages
-{%- if not grains.get('noservices', False) %}
-
cinder_scsi_service:
service.running:
- names:
- iscsitarget
- open-iscsi
- enable: true
+ {% if grains.noservices is defined %}
+ - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+ {% endif %}
- watch:
- file: /etc/default/iscsitarget
{%- endif %}
-{%- endif %}
-
{%- if volume.storage.engine == 'hitachi_vsp' %}
{%- if grains.os_family == 'Debian' and volume.version == 'juno' %}