Merge "Added opportunity remove service item." into release/2019.2.0
diff --git a/keystone/client/server.sls b/keystone/client/server.sls
index 13cff88..87ef7eb 100644
--- a/keystone/client/server.sls
+++ b/keystone/client/server.sls
@@ -45,6 +45,7 @@
{%- endif %}
{% for service_name, service in server.get('service', {}).items() %}
+ {%- if service.get('status', 'present') == 'present' %}
keystone_{{ server_name }}_service_{{ service_name }}:
keystoneng.service_present:
@@ -61,18 +62,12 @@
- connection_auth_url: {{ connection_args.auth_url }}
{%- endif %}
-{%- for endpoint in service.get('endpoints', ()) %}
- {%- if endpoint.get('status', 'present') == 'present' %}
+ {%- elif service.get('status', 'present') == 'absent' %}
+ {#- In case service is removed related endpoints will be removed automatically. #}
-keystone_{{ server_name }}_service_{{ service_name }}_endpoint_{{ endpoint.region }}:
- keystoneng.endpoint_present:
+keystone_service_{{ service_name }}_{{ service.type }}_absent:
+ keystoneng.service_absent:
- name: {{ service_name }}
- - publicurl: '{{ endpoint.get('public_protocol', 'http') }}://{{ endpoint.public_address }}{% if not ((endpoint.get('public_protocol') == 'https' and endpoint.public_port|int == 443) or (endpoint.get('public_protocol') == 'http' and endpoint.public_port|int == 80)) %}:{{ endpoint.public_port }}{% endif %}{{ endpoint.public_path }}'
- - internalurl: '{{ endpoint.get('internal_protocol', 'http') }}://{{ endpoint.internal_address }}{% if not (endpoint.get('internal_protocol', 'http') == 'https' and endpoint.internal_port|int == 443) %}:{{ endpoint.internal_port }}{% endif %}{{ endpoint.internal_path }}'
- - adminurl: '{{ endpoint.get('admin_protocol', 'http') }}://{{ endpoint.admin_address }}{% if not (endpoint.get('admin_protocol', 'http') == 'https' and endpoint.admin_port|int == 443) %}:{{ endpoint.admin_port }}{% endif %}{{ endpoint.admin_path }}'
- - region: {{ endpoint.region }}
- - require:
- - keystoneng: keystone_{{ server_name }}_service_{{ service_name }}
{%- if server.admin.token is defined %}
- connection_token: {{ connection_args.token }}
- connection_endpoint: {{ connection_args.endpoint }}
@@ -83,7 +78,32 @@
- connection_auth_url: {{ connection_args.auth_url }}
{%- endif %}
- {%- elif endpoint.get('status', 'present') == 'absent' %}
+ {%- endif %}
+
+{%- if service.get('status', 'present') == 'present' %}
+ {%- for endpoint in service.get('endpoints', ()) %}
+ {%- if endpoint.get('status', 'present') == 'present' %}
+
+keystone_{{ server_name }}_service_{{ service_name }}_endpoint_{{ endpoint.region }}:
+ keystoneng.endpoint_present:
+ - name: {{ service_name }}
+ - publicurl: '{{ endpoint.get('public_protocol', 'http') }}://{{ endpoint.public_address }}{% if not ((endpoint.get('public_protocol') == 'https' and endpoint.public_port|int == 443) or (endpoint.get('public_protocol') == 'http' and endpoint.public_port|int == 80)) %}:{{ endpoint.public_port }}{% endif %}{{ endpoint.public_path }}'
+ - internalurl: '{{ endpoint.get('internal_protocol', 'http') }}://{{ endpoint.internal_address }}{% if not (endpoint.get('internal_protocol', 'http') == 'https' and endpoint.internal_port|int == 443) %}:{{ endpoint.internal_port }}{% endif %}{{ endpoint.internal_path }}'
+ - adminurl: '{{ endpoint.get('admin_protocol', 'http') }}://{{ endpoint.admin_address }}{% if not (endpoint.get('admin_protocol', 'http') == 'https' and endpoint.admin_port|int == 443) %}:{{ endpoint.admin_port }}{% endif %}{{ endpoint.admin_path }}'
+ - region: {{ endpoint.region }}
+ - require:
+ - keystoneng: keystone_{{ server_name }}_service_{{ service_name }}
+ {%- if server.admin.token is defined %}
+ - connection_token: {{ connection_args.token }}
+ - connection_endpoint: {{ connection_args.endpoint }}
+ {%- else %}
+ - connection_user: {{ connection_args.user }}
+ - connection_password: {{ connection_args.password }}
+ - connection_tenant: {{ connection_args.tenant }}
+ - connection_auth_url: {{ connection_args.auth_url }}
+ {%- endif %}
+
+ {%- elif endpoint.get('status', 'present') == 'absent' %}
keystone_{{ server_name }}_service_{{ service_name }}_endpoint_{{ endpoint.region }}_absent:
keystoneng.endpoint_absent:
@@ -91,19 +111,20 @@
- region: {{ endpoint.region }}
- require:
- keystoneng: keystone_{{ server_name }}_service_{{ service_name }}
- {%- if server.admin.token is defined %}
+ {%- if server.admin.token is defined %}
- connection_token: {{ connection_args.token }}
- connection_endpoint: {{ connection_args.endpoint }}
- {%- else %}
+ {%- else %}
- connection_user: {{ connection_args.user }}
- connection_password: {{ connection_args.password }}
- connection_tenant: {{ connection_args.tenant }}
- connection_auth_url: {{ connection_args.auth_url }}
+ {%- endif %}
+
{%- endif %}
- {%- endif %}
-
-{%- endfor %}
+ {%- endfor %}
+{%- endif %}
{%- endfor %}