diff --git a/ansible/roles/aodh/tasks/check-containers.yml b/ansible/roles/aodh/tasks/check-containers.yml index 2f263c4f70..ae2a212427 100644 --- a/ansible/roles/aodh/tasks/check-containers.yml +++ b/ansible/roles/aodh/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ aodh_services }}" + with_dict: "{{ aodh_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/aodh/tasks/config.yml b/ansible/roles/aodh/tasks/config.yml index 0f5d0c1e7e..cb5ae253e7 100644 --- a/ansible/roles/aodh/tasks/config.yml +++ b/ansible/roles/aodh/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ aodh_services }}" + with_dict: "{{ aodh_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -39,9 +36,7 @@ become: true when: - aodh_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ aodh_services }}" + with_dict: "{{ aodh_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -55,10 +50,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ aodh_services }}" + with_dict: "{{ aodh_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -75,10 +67,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/aodh.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ aodh_services }}" + with_dict: "{{ aodh_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -90,8 +79,6 @@ dest: "{{ node_config_directory }}/aodh-api/wsgi-aodh.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart aodh-api container" diff --git a/ansible/roles/barbican/tasks/check-containers.yml b/ansible/roles/barbican/tasks/check-containers.yml index d9dd4be716..13a763e7dd 100644 --- a/ansible/roles/barbican/tasks/check-containers.yml +++ b/ansible/roles/barbican/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ barbican_services }}" + with_dict: "{{ barbican_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/barbican/tasks/config.yml b/ansible/roles/barbican/tasks/config.yml index 4d48f4bd06..cec2d566c1 100644 --- a/ansible/roles/barbican/tasks/config.yml +++ b/ansible/roles/barbican/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ barbican_services }}" + with_dict: "{{ barbican_services | select_services_enabled_and_mapped_to_host }}" - name: Ensuring vassals config directories exist vars: @@ -22,9 +19,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - "barbican-api/vassals" @@ -57,10 +52,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ barbican_services }}" + with_dict: "{{ barbican_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -75,9 +67,7 @@ dest: "{{ node_config_directory }}/barbican-api/vassals/barbican-api.ini" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart barbican-api container @@ -89,9 +79,7 @@ run_once: True delegate_to: localhost register: check_barbican_api_paste_ini - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Copying over barbican-api-paste.ini vars: @@ -102,8 +90,7 @@ mode: "0660" become: true when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - check_barbican_api_paste_ini.stat.exists notify: - Restart barbican-api container @@ -121,10 +108,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/barbican.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ barbican_services }}" + with_dict: "{{ barbican_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -136,8 +120,6 @@ become: true when: - barbican_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ barbican_services }}" + with_dict: "{{ barbican_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/blazar/tasks/check-containers.yml b/ansible/roles/blazar/tasks/check-containers.yml index 8cf2718905..b1a3b9cc88 100644 --- a/ansible/roles/blazar/tasks/check-containers.yml +++ b/ansible/roles/blazar/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ blazar_services }}" + with_dict: "{{ blazar_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/blazar/tasks/config.yml b/ansible/roles/blazar/tasks/config.yml index 24c9e0c536..f717ea34c5 100644 --- a/ansible/roles/blazar/tasks/config.yml +++ b/ansible/roles/blazar/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ blazar_services }}" + with_dict: "{{ blazar_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ blazar_services }}" + with_dict: "{{ blazar_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -61,10 +55,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/blazar.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ blazar_services }}" + with_dict: "{{ blazar_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -76,8 +67,6 @@ become: true when: - blazar_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ blazar_services }}" + with_dict: "{{ blazar_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/ceilometer/tasks/check-containers.yml b/ansible/roles/ceilometer/tasks/check-containers.yml index 8bedd1b503..dec2865e3a 100644 --- a/ansible/roles/ceilometer/tasks/check-containers.yml +++ b/ansible/roles/ceilometer/tasks/check-containers.yml @@ -10,9 +10,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/ceilometer/tasks/config.yml b/ansible/roles/ceilometer/tasks/config.yml index 02b575fd50..79a5ed25f6 100644 --- a/ansible/roles/ceilometer/tasks/config.yml +++ b/ansible/roles/ceilometer/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" - name: Check if the folder for custom meter definitions exist stat: @@ -42,11 +39,9 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" when: - should_copy_custom_meter_definitions - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - name: Copying custom meter definitions to Ceilometer copy: @@ -57,9 +52,7 @@ become: true when: - should_copy_custom_meter_definitions - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -118,9 +111,7 @@ become: true when: - ceilometer_polling_file.stat.exists - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -145,9 +136,7 @@ become: true when: - ceilometer_gnocchi_resources_file.stat.exists - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -186,10 +175,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -206,10 +192,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/ceilometer.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -231,8 +214,7 @@ register: ceilometer_event_definitions_overwriting when: - ceilometer_event_definitions_file.stat.exists - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart ceilometer-notification container @@ -246,8 +228,7 @@ become: true register: ceilometer_event_definitions when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - not ceilometer_event_definitions_file.stat.exists notify: - Restart ceilometer-notification container @@ -263,9 +244,7 @@ dest: "{{ node_config_directory }}/ceilometer-notification/event_pipeline.yaml" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart ceilometer-notification container @@ -290,10 +269,8 @@ register: ceilometer_pipeline_overwriting when: - ceilometer_pipeline_file.stat.exists - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - item.key in services_require_pipeline - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -309,11 +286,9 @@ mode: "0660" become: true when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - item.key in services_require_pipeline - not ceilometer_pipeline_file.stat.exists - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -328,8 +303,7 @@ when: - nova_compute_virt_type == "vmware" - not vmware_vcenter_insecure | bool - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart ceilometer-compute container @@ -341,8 +315,6 @@ become: true when: - ceilometer_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ceilometer_services }}" + with_dict: "{{ ceilometer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/cinder/tasks/check-containers.yml b/ansible/roles/cinder/tasks/check-containers.yml index c3f5ac2a20..50595bbc80 100644 --- a/ansible/roles/cinder/tasks/check-containers.yml +++ b/ansible/roles/cinder/tasks/check-containers.yml @@ -12,9 +12,6 @@ healthcheck: "{{ item.value.healthcheck | default(omit) }}" privileged: "{{ item.value.privileged | default(False) }}" ipc_mode: "{{ item.value.ipc_mode | default('') }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cinder_services }}" + with_dict: "{{ cinder_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/cinder/tasks/config.yml b/ansible/roles/cinder/tasks/config.yml index 493ebb6a56..754adc945c 100644 --- a/ansible/roles/cinder/tasks/config.yml +++ b/ansible/roles/cinder/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cinder_services }}" + with_dict: "{{ cinder_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: external_ceph.yml when: @@ -47,10 +44,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cinder_services }}" + with_dict: "{{ cinder_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -66,9 +60,7 @@ - "{{ node_custom_config }}/cinder/{{ inventory_hostname }}/cinder-wsgi.conf" - "{{ node_custom_config }}/cinder/cinder-wsgi.conf" - "cinder-wsgi.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart cinder-api container @@ -85,10 +77,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/cinder.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ cinder_services }}" + with_dict: "{{ cinder_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -101,9 +90,7 @@ dest: "{{ node_config_directory }}/cinder-volume/hostnqn" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart cinder-volume container @@ -114,14 +101,14 @@ dest: "{{ node_config_directory }}/{{ item.key }}/{{ cinder_policy_file }}" mode: "0660" when: - - item.value.enabled | bool - cinder_policy_file is defined - - inventory_hostname in groups[item.value.group] - with_dict: "{{ cinder_services }}" + with_dict: "{{ cinder_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" - name: Copying over nfs_shares files for cinder_volume + vars: + service: "{{ cinder_services['cinder-volume'] }}" become: true template: src: "{{ item }}" @@ -138,6 +125,6 @@ - "{{ node_custom_config }}/cinder/cinder-volume/nfs_shares" - "{{ node_custom_config }}/cinder/{{ inventory_hostname }}/nfs_shares" skip: "{{ not enable_cinder_backend_nfs | bool and not enable_cinder_backend_hnas_nfs | bool }}" - when: inventory_hostname in groups['cinder-volume'] + when: service | service_enabled_and_mapped_to_host notify: - Restart cinder-volume container diff --git a/ansible/roles/cinder/tasks/external_ceph.yml b/ansible/roles/cinder/tasks/external_ceph.yml index 8086092bc0..96bc8cc8cd 100644 --- a/ansible/roles/cinder/tasks/external_ceph.yml +++ b/ansible/roles/cinder/tasks/external_ceph.yml @@ -9,9 +9,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - "cinder-volume" - "cinder-backup" @@ -32,8 +30,7 @@ mode: "0660" become: true when: - - service.enabled | bool - - inventory_hostname in groups[service.group] + - service | service_enabled_and_mapped_to_host - service_name in services_need_config with_nested: - "{{ cinder_services | dict2items }}" @@ -44,6 +41,7 @@ - name: Copy over Ceph keyring files for cinder-volume vars: keyring: "{{ item.cluster }}.{{ ceph_cinder_keyring }}" + service: "{{ cinder_services['cinder-volume'] }}" template: src: "{{ node_custom_config }}/cinder/cinder-volume/{{ keyring }}" dest: "{{ node_config_directory }}/cinder-volume/ceph/{{ keyring }}" @@ -52,12 +50,13 @@ with_items: "{{ cinder_ceph_backends }}" when: - external_ceph_cephx_enabled | bool - - inventory_hostname in groups['cinder-volume'] - - cinder_services['cinder-volume'].enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart cinder-volume container - name: Copy over Ceph keyring files for cinder-backup + vars: + service: "{{ cinder_services['cinder-backup'] }}" template: src: "{{ node_custom_config }}/cinder/cinder-backup/{{ item }}" dest: "{{ node_config_directory }}/cinder-backup/ceph/{{ item }}" @@ -69,8 +68,7 @@ - "{{ cinder_backup_ceph_backend.cluster }}.{{ ceph_cinder_backup_keyring }}" when: - external_ceph_cephx_enabled | bool - - inventory_hostname in groups['cinder-backup'] - - cinder_services['cinder-backup'].enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart cinder-backup container diff --git a/ansible/roles/cloudkitty/tasks/check-containers.yml b/ansible/roles/cloudkitty/tasks/check-containers.yml index 435ee43de4..73fdcf74bd 100644 --- a/ansible/roles/cloudkitty/tasks/check-containers.yml +++ b/ansible/roles/cloudkitty/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cloudkitty_services }}" + with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/cloudkitty/tasks/config.yml b/ansible/roles/cloudkitty/tasks/config.yml index 967b8cab36..ce1c27f8c1 100644 --- a/ansible/roles/cloudkitty/tasks/config.yml +++ b/ansible/roles/cloudkitty/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cloudkitty_services }}" + with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -45,9 +42,7 @@ become: true when: - cloudkitty_custom_metrics_file.stat.exists - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cloudkitty_services }}" + with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -65,10 +60,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ cloudkitty_services }}" + with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -85,10 +77,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/cloudkitty.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cloudkitty_services }}" + with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -100,9 +89,7 @@ dest: "{{ node_config_directory }}/cloudkitty-api/wsgi-cloudkitty.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart cloudkitty-api container @@ -114,8 +101,6 @@ become: true when: - cloudkitty_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cloudkitty_services }}" + with_dict: "{{ cloudkitty_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/collectd/tasks/check-containers.yml b/ansible/roles/collectd/tasks/check-containers.yml index 18562710b4..8205876670 100644 --- a/ansible/roles/collectd/tasks/check-containers.yml +++ b/ansible/roles/collectd/tasks/check-containers.yml @@ -9,9 +9,6 @@ privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ collectd_services }}" + with_dict: "{{ collectd_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/collectd/tasks/config.yml b/ansible/roles/collectd/tasks/config.yml index 6b82fca9fe..44ea5adc1c 100644 --- a/ansible/roles/collectd/tasks/config.yml +++ b/ansible/roles/collectd/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ collectd_services }}" + with_dict: "{{ collectd_services | select_services_enabled_and_mapped_to_host }}" - name: Ensuring Plugin directory exist file: @@ -20,10 +17,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ collectd_services }}" + with_dict: "{{ collectd_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -31,10 +25,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ collectd_services }}" + with_dict: "{{ collectd_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart collectd container @@ -51,8 +42,6 @@ - "{{ node_custom_config }}/collectd/collectd.conf" - "{{ node_custom_config }}/collectd.conf" - "collectd.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart collectd container diff --git a/ansible/roles/common/tasks/check-containers.yml b/ansible/roles/common/tasks/check-containers.yml index 8550d8af52..1aa8b20739 100644 --- a/ansible/roles/common/tasks/check-containers.yml +++ b/ansible/roles/common/tasks/check-containers.yml @@ -10,8 +10,6 @@ dimensions: "{{ item.value.dimensions }}" privileged: "{{ item.value.privileged | default(False) }}" environment: "{{ item.value.environment }}" - when: - - item.value | service_enabled_and_mapped_to_host - with_dict: "{{ common_services }}" + with_dict: "{{ common_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 06c2b8556e..f0ccf4cc0f 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -96,8 +96,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: item.value | service_enabled_and_mapped_to_host - with_dict: "{{ common_services }}" + with_dict: "{{ common_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -289,9 +288,8 @@ mode: "0770" ignore_errors: "{{ ansible_check_mode }}" when: - - item.value | service_enabled_and_mapped_to_host - item.key != "kolla-toolbox" - with_dict: "{{ common_services }}" + with_dict: "{{ common_services | select_services_enabled_and_mapped_to_host }}" - name: Copy rabbitmq-env.conf to kolla toolbox template: diff --git a/ansible/roles/cyborg/tasks/check-containers.yml b/ansible/roles/cyborg/tasks/check-containers.yml index 9953f7b827..a7bcb4b973 100644 --- a/ansible/roles/cyborg/tasks/check-containers.yml +++ b/ansible/roles/cyborg/tasks/check-containers.yml @@ -10,9 +10,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cyborg_services }}" + with_dict: "{{ cyborg_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/cyborg/tasks/config.yml b/ansible/roles/cyborg/tasks/config.yml index 61dcb68ec2..863e123766 100644 --- a/ansible/roles/cyborg/tasks/config.yml +++ b/ansible/roles/cyborg/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ cyborg_services }}" + with_dict: "{{ cyborg_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -39,9 +36,7 @@ become: true when: - cyborg_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ cyborg_services }}" + with_dict: "{{ cyborg_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -55,10 +50,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ cyborg_services }}" + with_dict: "{{ cyborg_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -75,10 +67,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/cyborg.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ cyborg_services }}" + with_dict: "{{ cyborg_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -92,8 +81,6 @@ dest: "{{ node_config_directory }}/cyborg-api/api-paste.ini" mode: "0660" become: true - when: - - inventory_hostname in groups['cyborg-api'] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart cyborg-api container diff --git a/ansible/roles/designate/tasks/backend_external.yml b/ansible/roles/designate/tasks/backend_external.yml index 06cf3af959..67a1990f87 100644 --- a/ansible/roles/designate/tasks/backend_external.yml +++ b/ansible/roles/designate/tasks/backend_external.yml @@ -8,9 +8,7 @@ when: - designate_backend_external == 'bind9' - item.key in [ "designate-worker" ] - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -23,8 +21,6 @@ when: - designate_backend_external == 'bind9' - item.key in [ "designate-worker" ] - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/designate/tasks/check-containers.yml b/ansible/roles/designate/tasks/check-containers.yml index 9edee64580..1dfe7ca1e6 100644 --- a/ansible/roles/designate/tasks/check-containers.yml +++ b/ansible/roles/designate/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/designate/tasks/config.yml b/ansible/roles/designate/tasks/config.yml index 92a2d47fcf..74ef7b55ab 100644 --- a/ansible/roles/designate/tasks/config.yml +++ b/ansible/roles/designate/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -61,10 +55,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/designate.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -76,9 +67,7 @@ dest: "{{ node_config_directory }}/designate-worker/pools.yaml" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/designate/pools.yaml" - "{{ role_path }}/templates/pools.yaml.j2" @@ -95,8 +84,7 @@ become: true when: - designate_backend == 'bind9' - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/designate/designate-backend-bind9/{{ inventory_hostname }}/named.conf" - "{{ node_custom_config }}/designate/designate-backend-bind9/named.conf" @@ -114,9 +102,7 @@ when: - designate_backend == 'bind9' and designate_backend_external == 'no' - item.key in [ "designate-backend-bind9", "designate-worker" ] - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -129,9 +115,7 @@ when: - designate_backend == 'bind9' and designate_backend_external == 'no' - item.key in [ "designate-backend-bind9", "designate-worker" ] - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -146,8 +130,6 @@ become: true when: - designate_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ designate_services }}" + with_dict: "{{ designate_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/etcd/tasks/check-containers.yml b/ansible/roles/etcd/tasks/check-containers.yml index 3a19a4a873..11e9b54343 100644 --- a/ansible/roles/etcd/tasks/check-containers.yml +++ b/ansible/roles/etcd/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment }}" - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ etcd_services }}" + with_dict: "{{ etcd_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/etcd/tasks/config.yml b/ansible/roles/etcd/tasks/config.yml index e3fc555405..cd780bad76 100644 --- a/ansible/roles/etcd/tasks/config.yml +++ b/ansible/roles/etcd/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ etcd_services }}" + with_dict: "{{ etcd_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -18,10 +15,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ etcd_services }}" + with_dict: "{{ etcd_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/glance/tasks/check-containers.yml b/ansible/roles/glance/tasks/check-containers.yml index 763ded8637..641ba907fd 100644 --- a/ansible/roles/glance/tasks/check-containers.yml +++ b/ansible/roles/glance/tasks/check-containers.yml @@ -11,9 +11,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - item.value.host_in_groups | bool - - item.value.enabled | bool - with_dict: "{{ glance_services }}" + with_dict: "{{ glance_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/glance/tasks/config.yml b/ansible/roles/glance/tasks/config.yml index 702501d7a9..f98aefc29e 100644 --- a/ansible/roles/glance/tasks/config.yml +++ b/ansible/roles/glance/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - item.value.host_in_groups | bool - - item.value.enabled | bool - with_dict: "{{ glance_services }}" + with_dict: "{{ glance_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: external_ceph.yml when: @@ -41,7 +38,7 @@ - name: Creating TLS backend PEM File vars: - glance_tls_proxy: "{{ glance_services['glance-tls-proxy'] }}" + service: "{{ glance_services['glance-tls-proxy'] }}" assemble: src: "{{ node_config_directory }}/glance-tls-proxy/" dest: "{{ node_config_directory }}/glance-tls-proxy/glance-cert-and-key.pem" @@ -49,9 +46,7 @@ regexp: "^glance-(cert|key)\\.pem$" remote_src: true become: true - when: - - glance_tls_proxy.enabled | bool - - glance_tls_proxy.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host - name: Copying over config.json files for services template: @@ -59,16 +54,13 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ glance_services }}" + with_dict: "{{ glance_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container - name: Copying over glance-api.conf vars: - glance_api: "{{ glance_services['glance-api'] }}" + service: "{{ glance_services['glance-api'] }}" merge_configs: sources: - "{{ role_path }}/templates/glance-api.conf.j2" @@ -79,15 +71,13 @@ dest: "{{ node_config_directory }}/glance-api/glance-api.conf" mode: "0660" become: true - when: - - glance_api.enabled | bool - - glance_api.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart glance-api container - name: Copying over glance-cache.conf for glance_api vars: - glance_api: "{{ glance_services['glance-api'] }}" + service: "{{ glance_services['glance-api'] }}" merge_configs: sources: - "{{ role_path }}/templates/glance-cache.conf.j2" @@ -98,15 +88,14 @@ mode: "0660" become: true when: - - glance_api.enabled | bool - - glance_api.host_in_groups | bool + - service | service_enabled_and_mapped_to_host - enable_glance_image_cache | bool notify: - Restart glance-api container - name: Copying over glance-swift.conf for glance_api vars: - glance_api: "{{ glance_services['glance-api'] }}" + service: "{{ glance_services['glance-api'] }}" merge_configs: sources: - "{{ role_path }}/templates/glance-swift.conf.j2" @@ -117,45 +106,42 @@ mode: "0660" become: true when: - - glance_api.enabled | bool - - glance_api.host_in_groups | bool + - service | service_enabled_and_mapped_to_host - glance_backend_swift | bool notify: - Restart glance-api container - name: Copying over glance-image-import.conf vars: - glance_api: "{{ glance_services['glance-api'] }}" + service: "{{ glance_services['glance-api'] }}" copy: src: "{{ node_custom_config }}/glance/glance-image-import.conf" dest: "{{ node_config_directory }}/glance-api/glance-image-import.conf" mode: "0660" become: true when: - - glance_api.enabled | bool - - inventory_hostname in groups[glance_api.group] + - service | service_enabled_and_mapped_to_host - glance_enable_interoperable_image_import | bool notify: - Restart glance-api container - name: Copying over property-protections-rules.conf vars: - glance_api: "{{ glance_services['glance-api'] }}" + service: "{{ glance_services['glance-api'] }}" copy: src: "{{ node_custom_config }}/glance/property-protections-rules.conf" dest: "{{ node_config_directory }}/glance-api/property-protections-rules.conf" mode: "0660" become: true when: - - glance_api.enabled | bool - - inventory_hostname in groups[glance_api.group] + - service | service_enabled_and_mapped_to_host - glance_enable_property_protection | bool notify: - Restart glance-api container - name: Copying over existing policy file vars: - glance_api: "{{ glance_services['glance-api'] }}" + service: "{{ glance_services['glance-api'] }}" template: src: "{{ glance_policy_file_path }}" dest: "{{ node_config_directory }}/glance-api/{{ glance_policy_file }}" @@ -163,14 +149,13 @@ become: true when: - glance_policy_file is defined - - glance_api.host_in_groups | bool - - glance_api.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart glance-api container - name: Copying over glance-haproxy-tls.cfg vars: - glance_tls_proxy: "{{ glance_services['glance-tls-proxy'] }}" + service: "{{ glance_services['glance-tls-proxy'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/glance-tls-proxy/glance-tls-proxy.cfg" @@ -180,8 +165,6 @@ - "{{ node_custom_config }}/glance/{{ inventory_hostname }}/glance-tls-proxy.cfg" - "{{ node_custom_config }}/glance/glance-tls-proxy.cfg" - "glance-tls-proxy.cfg.j2" - when: - - glance_tls_proxy.enabled | bool - - glance_tls_proxy.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart glance-tls-proxy container diff --git a/ansible/roles/glance/tasks/external_ceph.yml b/ansible/roles/glance/tasks/external_ceph.yml index da0a35fe3d..ad3587ec34 100644 --- a/ansible/roles/glance/tasks/external_ceph.yml +++ b/ansible/roles/glance/tasks/external_ceph.yml @@ -9,9 +9,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Copy over multiple ceph configs for Glance merge_configs: diff --git a/ansible/roles/glance/tasks/precheck.yml b/ansible/roles/glance/tasks/precheck.yml index 362d62d908..775bd58a66 100644 --- a/ansible/roles/glance/tasks/precheck.yml +++ b/ansible/roles/glance/tasks/precheck.yml @@ -14,6 +14,8 @@ register: container_facts - name: Checking free port for Glance API + vars: + service: "{{ glance_services['glance-api'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ glance_api_listen_port }}" @@ -21,8 +23,7 @@ timeout: 1 state: stopped when: - - glance_services['glance-api'].host_in_groups | bool - - glance_services['glance-api'].enabled | bool + - service | service_enabled_and_mapped_to_host - container_facts['glance_api'] is not defined - name: Check if S3 configurations are defined diff --git a/ansible/roles/glance/tasks/stop_service.yml b/ansible/roles/glance/tasks/stop_service.yml index ecce6c4f0c..e45a49d2ae 100644 --- a/ansible/roles/glance/tasks/stop_service.yml +++ b/ansible/roles/glance/tasks/stop_service.yml @@ -1,12 +1,10 @@ --- - name: Stop glance service vars: - glance_api: "{{ glance_services['glance-api'] }}" + service: "{{ glance_services['glance-api'] }}" become: true kolla_container: action: "stop_container" common_options: "{{ docker_common_options }}" - name: "{{ glance_api.container_name }}" - when: - - glance_api.host_in_groups | bool - - glance_api.enabled | bool + name: "{{ service.container_name }}" + when: service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/gnocchi/tasks/check-containers.yml b/ansible/roles/gnocchi/tasks/check-containers.yml index 4e9820408b..4369977f29 100644 --- a/ansible/roles/gnocchi/tasks/check-containers.yml +++ b/ansible/roles/gnocchi/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ gnocchi_services }}" + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/gnocchi/tasks/config.yml b/ansible/roles/gnocchi/tasks/config.yml index 98448789f3..48a0521ebb 100644 --- a/ansible/roles/gnocchi/tasks/config.yml +++ b/ansible/roles/gnocchi/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ gnocchi_services }}" + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: external_ceph.yml when: @@ -45,10 +42,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ gnocchi_services }}" + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -65,10 +59,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/gnocchi.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ gnocchi_services }}" + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -80,9 +71,7 @@ dest: "{{ node_config_directory }}/{{ item }}/wsgi-gnocchi.conf" mode: "0660" become: true - when: - - inventory_hostname in groups['gnocchi-api'] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - "gnocchi-api" notify: @@ -96,8 +85,6 @@ become: true when: - gnocchi_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ gnocchi_services }}" + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/gnocchi/tasks/external_ceph.yml b/ansible/roles/gnocchi/tasks/external_ceph.yml index 14d6948a7c..6f01494e71 100644 --- a/ansible/roles/gnocchi/tasks/external_ceph.yml +++ b/ansible/roles/gnocchi/tasks/external_ceph.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - with_dict: "{{ gnocchi_services }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" - name: Copy over ceph config for Gnocchi merge_configs: @@ -20,10 +17,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/ceph/{{ gnocchi_ceph_cluster }}.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ gnocchi_services }}" + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -33,10 +27,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/ceph/{{ gnocchi_ceph_cluster }}.{{ ceph_gnocchi_keyring }}" mode: "0660" become: true - with_dict: "{{ gnocchi_services }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -47,7 +38,4 @@ recurse: yes owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ gnocchi_services }}" + with_dict: "{{ gnocchi_services | select_services_enabled_and_mapped_to_host }}" diff --git a/ansible/roles/grafana/tasks/check-containers.yml b/ansible/roles/grafana/tasks/check-containers.yml index 8f2ede7cc9..4c24c3b50e 100644 --- a/ansible/roles/grafana/tasks/check-containers.yml +++ b/ansible/roles/grafana/tasks/check-containers.yml @@ -8,9 +8,6 @@ image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ grafana_services }}" + with_dict: "{{ grafana_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/grafana/tasks/config.yml b/ansible/roles/grafana/tasks/config.yml index cc12d874a8..cf5cd23efc 100644 --- a/ansible/roles/grafana/tasks/config.yml +++ b/ansible/roles/grafana/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ grafana_services }}" + with_dict: "{{ grafana_services | select_services_enabled_and_mapped_to_host }}" - name: Check if extra configuration file exists find: @@ -30,10 +27,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ grafana_services }}" + with_dict: "{{ grafana_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -48,10 +42,7 @@ dest: "{{ node_config_directory }}/grafana/grafana.ini" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ grafana_services }}" + with_dict: "{{ grafana_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -94,8 +85,7 @@ mode: "0660" become: true when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - enable_prometheus | bool with_first_found: - "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/prometheus.yaml" @@ -112,9 +102,7 @@ dest: "{{ node_config_directory }}/grafana/provisioning.yaml" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/provisioning.yaml" - "{{ node_custom_config }}/grafana/provisioning.yaml" @@ -136,9 +124,7 @@ file: state: absent path: "{{ node_config_directory }}/grafana/dashboards/" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Copying over custom dashboards vars: @@ -151,7 +137,6 @@ when: - grafana_custom_dashboards_folder.stat.exists - grafana_custom_dashboards_folder.stat.isdir - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart grafana container diff --git a/ansible/roles/hacluster/tasks/bootstrap_service.yml b/ansible/roles/hacluster/tasks/bootstrap_service.yml index 3669143f23..40f0507dde 100644 --- a/ansible/roles/hacluster/tasks/bootstrap_service.yml +++ b/ansible/roles/hacluster/tasks/bootstrap_service.yml @@ -10,7 +10,7 @@ - name: Ensure remote node is added vars: pacemaker_service: "{{ hacluster_services['hacluster-pacemaker'] }}" - pacemaker_remote_service: "{{ hacluster_services['hacluster-pacemaker-remote'] }}" + service: "{{ hacluster_services['hacluster-pacemaker-remote'] }}" shell: > {{ kolla_container_engine }} exec {{ pacemaker_service.container_name }} cibadmin --modify --scope resources -X ' @@ -27,6 +27,4 @@ ' become: true delegate_to: "{{ groups[pacemaker_service.group][0] }}" - when: - - inventory_hostname in groups[pacemaker_remote_service.group] - - pacemaker_remote_service.enabled | bool + when: service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/hacluster/tasks/config.yml b/ansible/roles/hacluster/tasks/config.yml index 1380e66185..e33f7cf481 100644 --- a/ansible/roles/hacluster/tasks/config.yml +++ b/ansible/roles/hacluster/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ hacluster_services }}" + with_dict: "{{ hacluster_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services become: true @@ -19,10 +16,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" register: config_jsons - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ hacluster_services }}" + with_dict: "{{ hacluster_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -34,9 +28,7 @@ dest: "{{ node_config_directory }}/hacluster-corosync/corosync.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/hacluster-corosync/{{ inventory_hostname }}/corosync.conf" - "{{ node_custom_config }}/hacluster-corosync/corosync.conf" @@ -52,9 +44,7 @@ dest: "{{ node_config_directory }}/hacluster-corosync/authkey" mode: "0600" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/hacluster-corosync/{{ inventory_hostname }}/authkey" - "{{ node_custom_config }}/hacluster-corosync/authkey" @@ -69,9 +59,7 @@ dest: "{{ node_config_directory }}//hacluster-pacemaker/authkey" mode: "0600" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/hacluster-pacemaker/{{ inventory_hostname }}/authkey" - "{{ node_custom_config }}/hacluster-pacemaker/authkey" @@ -86,9 +74,7 @@ dest: "{{ node_config_directory }}/hacluster-pacemaker-remote/authkey" mode: "0600" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/hacluster-pacemaker/{{ inventory_hostname }}/authkey" - "{{ node_custom_config }}/hacluster-pacemaker/authkey" diff --git a/ansible/roles/heat/tasks/check-containers.yml b/ansible/roles/heat/tasks/check-containers.yml index fbe52d9b41..9ac2c53f4f 100644 --- a/ansible/roles/heat/tasks/check-containers.yml +++ b/ansible/roles/heat/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ heat_services }}" + with_dict: "{{ heat_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/heat/tasks/config.yml b/ansible/roles/heat/tasks/config.yml index 37e6539154..ec7226a7d5 100644 --- a/ansible/roles/heat/tasks/config.yml +++ b/ansible/roles/heat/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ heat_services }}" + with_dict: "{{ heat_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ heat_services }}" + with_dict: "{{ heat_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -61,10 +55,7 @@ - "{{ node_custom_config }}/heat/{{ inventory_hostname }}/heat.conf" dest: "{{ node_config_directory }}/{{ item.key }}/heat.conf" mode: "0660" - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ heat_services }}" + with_dict: "{{ heat_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -76,9 +67,7 @@ mode: "0660" when: - heat_policy_file is defined - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ heat_services }}" + with_dict: "{{ heat_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -90,9 +79,7 @@ dest: "{{ node_config_directory }}/heat-api/wsgi-heat-api.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service['group']] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart heat-api container @@ -104,8 +91,6 @@ dest: "{{ node_config_directory }}/heat-api-cfn/wsgi-heat-api-cfn.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service['group']] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart heat-api-cfn container diff --git a/ansible/roles/horizon/tasks/check-containers.yml b/ansible/roles/horizon/tasks/check-containers.yml index e956f35604..b7e38d8f5c 100644 --- a/ansible/roles/horizon/tasks/check-containers.yml +++ b/ansible/roles/horizon/tasks/check-containers.yml @@ -1,20 +1,15 @@ --- - name: Deploy horizon container - vars: - horizon: "{{ horizon_services['horizon'] }}" become: true kolla_container: action: "compare_container" common_options: "{{ docker_common_options }}" - name: "{{ horizon.container_name }}" - image: "{{ horizon.image }}" - environment: "{{ horizon.environment }}" - volumes: "{{ horizon.volumes }}" - dimensions: "{{ horizon.dimensions }}" - healthcheck: "{{ horizon.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[horizon.group] - - horizon.enabled | bool - with_dict: "{{ horizon_services }}" + name: "{{ item.value.container_name }}" + image: "{{ item.value.image }}" + environment: "{{ item.value.environment }}" + volumes: "{{ item.value.volumes }}" + dimensions: "{{ item.value.dimensions }}" + healthcheck: "{{ item.value.healthcheck | default(omit) }}" + with_dict: "{{ horizon_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/horizon/tasks/config.yml b/ansible/roles/horizon/tasks/config.yml index 912c078ff1..836b1aabb9 100644 --- a/ansible/roles/horizon/tasks/config.yml +++ b/ansible/roles/horizon/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ horizon_services }}" + with_dict: "{{ horizon_services | select_services_enabled_and_mapped_to_host }}" - name: Set empty custom policy set_fact: @@ -43,21 +40,19 @@ - name: Copying over config.json files for services become: true vars: - horizon: "{{ horizon_services['horizon'] }}" + service: "{{ horizon_services['horizon'] }}" template: src: "horizon.json.j2" dest: "{{ node_config_directory }}/horizon/config.json" mode: "0660" - when: - - horizon.enabled | bool - - inventory_hostname in groups[horizon.group] + when: service | service_enabled_and_mapped_to_host notify: - Restart horizon container - name: Copying over horizon.conf become: true vars: - horizon: "{{ horizon_services['horizon'] }}" + service: "{{ horizon_services['horizon'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/horizon/horizon.conf" @@ -66,16 +61,14 @@ - "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/horizon.conf" - "{{ node_custom_config }}/horizon/horizon.conf" - "horizon.conf.j2" - when: - - horizon.enabled | bool - - inventory_hostname in groups[horizon.group] + when: service | service_enabled_and_mapped_to_host notify: - Restart horizon container - name: Copying over kolla-settings.py become: true vars: - horizon: "{{ horizon_services['horizon'] }}" + service: "{{ horizon_services['horizon'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/horizon/_9998-kolla-settings.py" @@ -84,16 +77,14 @@ - "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/_9998-kolla-settings.py" - "{{ node_custom_config }}/horizon/_9998-kolla-settings.py" - "_9998-kolla-settings.py.j2" - when: - - horizon.enabled | bool - - inventory_hostname in groups[horizon.group] + when: service | service_enabled_and_mapped_to_host notify: - Restart horizon container - name: Copying over custom-settings.py become: true vars: - horizon: "{{ horizon_services['horizon'] }}" + service: "{{ horizon_services['horizon'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/horizon/_9999-custom-settings.py" @@ -102,23 +93,19 @@ - "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/_9999-custom-settings.py" - "{{ node_custom_config }}/horizon/_9999-custom-settings.py" - "_9999-custom-settings.py.j2" - when: - - horizon.enabled | bool - - inventory_hostname in groups[horizon.group] + when: service | service_enabled_and_mapped_to_host notify: - Restart horizon container - name: Copying over existing policy file become: true vars: - horizon: "{{ horizon_services['horizon'] }}" + service: "{{ horizon_services['horizon'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/horizon/{{ item | basename }}" mode: "0660" - when: - - horizon.enabled | bool - - inventory_hostname in groups[horizon.group] + when: service | service_enabled_and_mapped_to_host with_items: "{{ custom_policy }}" notify: - Restart horizon container @@ -126,14 +113,13 @@ - name: Copying over custom themes become: true vars: - horizon: "{{ horizon_services['horizon'] }}" + service: "{{ horizon_services['horizon'] }}" copy: src: "{{ node_custom_config }}/horizon/themes/{{ item.name }}" dest: "{{ node_config_directory }}/horizon/themes/" mode: 0660 when: - - horizon.enabled | bool - - inventory_hostname in groups[horizon.group] + - service | service_enabled_and_mapped_to_host - horizon_custom_themes | length > 0 with_items: "{{ horizon_custom_themes }}" notify: diff --git a/ansible/roles/influxdb/tasks/check-containers.yml b/ansible/roles/influxdb/tasks/check-containers.yml index 0036fd6403..ac14089716 100644 --- a/ansible/roles/influxdb/tasks/check-containers.yml +++ b/ansible/roles/influxdb/tasks/check-containers.yml @@ -8,9 +8,6 @@ image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ influxdb_services }}" + with_dict: "{{ influxdb_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/influxdb/tasks/config.yml b/ansible/roles/influxdb/tasks/config.yml index 841e7aeb7a..48c168de55 100644 --- a/ansible/roles/influxdb/tasks/config.yml +++ b/ansible/roles/influxdb/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ influxdb_services }}" + with_dict: "{{ influxdb_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files template: @@ -18,10 +15,7 @@ dest: "{{ node_config_directory }}/influxdb/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ influxdb_services }}" + with_dict: "{{ influxdb_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart influxdb container @@ -33,9 +27,7 @@ dest: "{{ node_config_directory }}/influxdb/influxdb.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/influxdb/{{ inventory_hostname }}/influxdb.conf" - "{{ node_custom_config }}/influxdb.conf" diff --git a/ansible/roles/ironic/tasks/bootstrap_service.yml b/ansible/roles/ironic/tasks/bootstrap_service.yml index c798c833f9..bb8a4e5e6e 100644 --- a/ansible/roles/ironic/tasks/bootstrap_service.yml +++ b/ansible/roles/ironic/tasks/bootstrap_service.yml @@ -47,7 +47,7 @@ - name: Running ironic-tftp bootstrap container vars: - ironic_tftp: "{{ ironic_services['ironic-tftp'] }}" + service: "{{ ironic_services['ironic-tftp'] }}" become: true kolla_container: action: "start_container" @@ -58,12 +58,10 @@ HTTPBOOT_PATH: /var/lib/ironic/httpboot KOLLA_BOOTSTRAP: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" - image: "{{ ironic_tftp.image }}" + image: "{{ service.image }}" labels: BOOTSTRAP: name: "bootstrap_ironic_tftp" restart_policy: oneshot - volumes: "{{ ironic_tftp.volumes }}" - when: - - inventory_hostname in groups[ironic_tftp.group] - - ironic_tftp.enabled | bool + volumes: "{{ service.volumes }}" + when: service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/ironic/tasks/check-containers.yml b/ansible/roles/ironic/tasks/check-containers.yml index 8bba5411fc..7ee5e77714 100644 --- a/ansible/roles/ironic/tasks/check-containers.yml +++ b/ansible/roles/ironic/tasks/check-containers.yml @@ -12,9 +12,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ironic_services }}" + with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/ironic/tasks/config.yml b/ansible/roles/ironic/tasks/config.yml index c17f2c335d..dc4cb4469e 100644 --- a/ansible/roles/ironic/tasks/config.yml +++ b/ansible/roles/ironic/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ironic_services }}" + with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}" - name: Check if Ironic policies shall be overwritten stat: @@ -60,10 +57,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ironic_services }}" + with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -82,9 +76,7 @@ become: true when: - item.key in [ "ironic-api", "ironic-conductor", "ironic-prometheus-exporter" ] - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ironic_services }}" + with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -101,9 +93,7 @@ dest: "{{ node_config_directory }}/ironic-inspector/inspector.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart ironic-inspector container @@ -115,9 +105,7 @@ dest: "{{ node_config_directory }}/ironic-dnsmasq/dnsmasq.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/ironic/ironic-dnsmasq.conf" - "{{ node_custom_config }}/ironic/{{ inventory_hostname }}/ironic-dnsmasq.conf" @@ -140,8 +128,7 @@ when: # Only required when Ironic inspector is in use. - groups['ironic-inspector'] | length > 0 - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - not ironic_dnsmasq_serve_ipxe | bool notify: - Restart ironic-tftp container @@ -160,8 +147,7 @@ when: # Only required when Ironic inspector is in use. - groups['ironic-inspector'] | length > 0 - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - not ironic_dnsmasq_serve_ipxe | bool notify: - Restart ironic-tftp container @@ -180,8 +166,7 @@ when: # Only required when Ironic inspector is in use. - groups['ironic-inspector'] | length > 0 - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart ironic-http container @@ -200,8 +185,7 @@ when: # Only required when Ironic inspector is in use. - groups['ironic-inspector'] | length > 0 - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart ironic-http container @@ -216,9 +200,7 @@ with_first_found: - "{{ node_custom_config }}/ironic/ironic-http-httpd.conf" - "ironic-http-httpd.conf.j2" - when: - - service.enabled | bool - - inventory_hostname in groups[service.group] + when: service | service_enabled_and_mapped_to_host notify: - Restart ironic-http container @@ -234,9 +216,7 @@ - "{{ node_config_directory }}/ironic/{{ inventory_hostname }}/ironic-prometheus-exporter-wsgi.conf" - "{{ node_config_directory }}/ironic/ironic-prometheus-exporter-wsgi.conf" - "ironic-prometheus-exporter-wsgi.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart ironic-prometheus-exporter container" @@ -253,9 +233,7 @@ when: - ironic_policy_file is defined - item.key in services_require_policy_json - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ironic_services }}" + with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -271,20 +249,18 @@ when: - ironic_inspector_policy_file is defined - item.key in services_require_inspector_policy_json - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ironic_services }}" + with_dict: "{{ ironic_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" - name: Copying over ironic-api-wsgi.conf + vars: + service: "{{ ironic_services['ironic-api'] }}" template: src: "ironic-api-wsgi.conf.j2" dest: "{{ node_config_directory }}/ironic-api/ironic-api-wsgi.conf" mode: "0660" become: true - when: - - inventory_hostname in groups["ironic-api"] - - ironic_services["ironic-api"].enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart ironic-api container" diff --git a/ansible/roles/iscsi/tasks/check-containers.yml b/ansible/roles/iscsi/tasks/check-containers.yml index 76cd9cd188..3eae52913a 100644 --- a/ansible/roles/iscsi/tasks/check-containers.yml +++ b/ansible/roles/iscsi/tasks/check-containers.yml @@ -10,9 +10,6 @@ privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ iscsi_services }}" + with_dict: "{{ iscsi_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/iscsi/tasks/config.yml b/ansible/roles/iscsi/tasks/config.yml index 1c9da9dfc0..563c969012 100644 --- a/ansible/roles/iscsi/tasks/config.yml +++ b/ansible/roles/iscsi/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ iscsi_services }}" + with_dict: "{{ iscsi_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -18,9 +15,6 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ iscsi_services }}" + with_dict: "{{ iscsi_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/keystone/tasks/check-containers.yml b/ansible/roles/keystone/tasks/check-containers.yml index 98184af696..226d979dc2 100644 --- a/ansible/roles/keystone/tasks/check-containers.yml +++ b/ansible/roles/keystone/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ keystone_services }}" + with_dict: "{{ keystone_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/keystone/tasks/config.yml b/ansible/roles/keystone/tasks/config.yml index a8d150c485..04325d5735 100644 --- a/ansible/roles/keystone/tasks/config.yml +++ b/ansible/roles/keystone/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ keystone_services }}" + with_dict: "{{ keystone_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -48,10 +45,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - with_dict: "{{ keystone_services }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool + with_dict: "{{ keystone_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -68,39 +62,34 @@ dest: "{{ node_config_directory }}/{{ item.key }}/keystone.conf" mode: "0660" become: true - with_dict: "{{ keystone_services }}" + with_dict: "{{ keystone_services | select_services_enabled_and_mapped_to_host }}" when: - - inventory_hostname in groups[item.value.group] - item.key in [ "keystone", "keystone-fernet" ] - - item.value.enabled | bool notify: - Restart {{ item.key }} container - name: Copying keystone-startup script for keystone vars: - keystone: "{{ keystone_services['keystone'] }}" + service: "{{ keystone_services['keystone'] }}" template: src: "keystone-startup.sh.j2" dest: "{{ node_config_directory }}/keystone/keystone-startup.sh" mode: "0660" become: true - when: - - inventory_hostname in groups[keystone.group] - - keystone.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart keystone container - name: Create Keystone domain-specific config directory vars: - keystone: "{{ keystone_services.keystone }}" + service: "{{ keystone_services['keystone'] }}" file: dest: "{{ node_config_directory }}/keystone/domains/" state: "directory" mode: "0770" become: true when: - - inventory_hostname in groups[keystone.group] - - keystone.enabled | bool + - service | service_enabled_and_mapped_to_host - keystone_domain_directory.stat.exists - name: Get file list in custom domains folder @@ -114,7 +103,7 @@ - name: Copying Keystone Domain specific settings vars: - keystone: "{{ keystone_services.keystone }}" + service: "{{ keystone_services['keystone'] }}" template: src: "{{ item.path }}" dest: "{{ node_config_directory }}/keystone/domains/" @@ -122,8 +111,7 @@ become: true register: keystone_domains when: - - inventory_hostname in groups[keystone.group] - - keystone.enabled | bool + - service | service_enabled_and_mapped_to_host - keystone_domain_directory.stat.exists with_items: "{{ keystone_domains.files | default([]) }}" notify: @@ -136,11 +124,9 @@ mode: "0660" become: true when: - - inventory_hostname in groups[item.value.group] - item.key in [ "keystone", "keystone-fernet" ] - - item.value.enabled | bool - keystone_policy_file is defined - with_dict: "{{ keystone_services }}" + with_dict: "{{ keystone_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -150,15 +136,13 @@ - name: Copying over wsgi-keystone.conf vars: - keystone: "{{ keystone_services.keystone }}" + service: "{{ keystone_services['keystone'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/keystone/wsgi-keystone.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[keystone.group] - - keystone.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/keystone/{{ inventory_hostname }}/wsgi-keystone.conf" - "{{ node_custom_config }}/keystone/wsgi-keystone.conf" @@ -168,26 +152,24 @@ - name: Checking whether keystone-paste.ini file exists vars: - keystone: "{{ keystone_services.keystone }}" + service: "{{ keystone_services['keystone'] }}" stat: path: "{{ node_custom_config }}/keystone/keystone-paste.ini" delegate_to: localhost run_once: True register: check_keystone_paste_ini - when: - - keystone.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Copying over keystone-paste.ini vars: - keystone: "{{ keystone_services.keystone }}" + service: "{{ keystone_services['keystone'] }}" template: src: "{{ node_custom_config }}/keystone/keystone-paste.ini" dest: "{{ node_config_directory }}/keystone/keystone-paste.ini" mode: "0660" become: true when: - - inventory_hostname in groups[keystone.group] - - keystone.enabled | bool + - service | service_enabled_and_mapped_to_host - check_keystone_paste_ini.stat.exists notify: - Restart keystone container @@ -211,7 +193,7 @@ - name: Copying files for keystone-fernet vars: - keystone_fernet: "{{ keystone_services['keystone-fernet'] }}" + service: "{{ keystone_services['keystone-fernet'] }}" template: src: "{{ item.src }}" dest: "{{ node_config_directory }}/keystone-fernet/{{ item.dest }}" @@ -226,15 +208,13 @@ - { src: "fernet-healthcheck.sh.j2", dest: "fernet-healthcheck.sh" } - { src: "id_rsa", dest: "id_rsa" } - { src: "ssh_config.j2", dest: "ssh_config" } - when: - - inventory_hostname in groups[keystone_fernet.group] - - keystone_fernet.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart keystone-fernet container - name: Copying files for keystone-ssh vars: - keystone_ssh: "{{ keystone_services['keystone-ssh'] }}" + service: "{{ keystone_services['keystone-ssh'] }}" template: src: "{{ item.src }}" dest: "{{ node_config_directory }}/keystone-ssh/{{ item.dest }}" @@ -243,8 +223,6 @@ with_items: - { src: "sshd_config.j2", dest: "sshd_config" } - { src: "id_rsa.pub", dest: "id_rsa.pub" } - when: - - inventory_hostname in groups[keystone_ssh.group] - - keystone_ssh.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart keystone-ssh container diff --git a/ansible/roles/kuryr/tasks/check-containers.yml b/ansible/roles/kuryr/tasks/check-containers.yml index 86e2f17162..c1fdb0c5ed 100644 --- a/ansible/roles/kuryr/tasks/check-containers.yml +++ b/ansible/roles/kuryr/tasks/check-containers.yml @@ -11,9 +11,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ kuryr_services }}" + with_dict: "{{ kuryr_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/kuryr/tasks/config.yml b/ansible/roles/kuryr/tasks/config.yml index c05971366a..f533c50dae 100644 --- a/ansible/roles/kuryr/tasks/config.yml +++ b/ansible/roles/kuryr/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ kuryr_services }}" + with_dict: "{{ kuryr_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ kuryr_services }}" + with_dict: "{{ kuryr_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart kuryr container @@ -61,10 +55,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/kuryr.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ kuryr_services }}" + with_dict: "{{ kuryr_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart kuryr container @@ -76,9 +67,7 @@ dest: "{{ node_config_directory }}/{{ item }}/kuryr.spec" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - "kuryr" notify: @@ -92,8 +81,6 @@ become: true when: - kuryr_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ kuryr_services }}" + with_dict: "{{ kuryr_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart kuryr container diff --git a/ansible/roles/letsencrypt/tasks/check-containers.yml b/ansible/roles/letsencrypt/tasks/check-containers.yml index 559baba739..0c20e05233 100644 --- a/ansible/roles/letsencrypt/tasks/check-containers.yml +++ b/ansible/roles/letsencrypt/tasks/check-containers.yml @@ -10,9 +10,6 @@ dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" environment: "{{ item.value.environment | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ letsencrypt_services }}" + with_dict: "{{ letsencrypt_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/letsencrypt/tasks/config.yml b/ansible/roles/letsencrypt/tasks/config.yml index 44011ee7eb..5117f9d1c0 100644 --- a/ansible/roles/letsencrypt/tasks/config.yml +++ b/ansible/roles/letsencrypt/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ letsencrypt_services }}" + with_dict: "{{ letsencrypt_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -18,10 +15,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ letsencrypt_services }}" + with_dict: "{{ letsencrypt_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -37,9 +31,7 @@ - "{{ node_custom_config }}/letsencrypt/{{ inventory_hostname }}/letsencrypt-webserver.conf" - "{{ node_custom_config }}/letsencrypt/letsencrypt-webserver.conf" - "letsencrypt-webserver.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart letsencrypt-webserver container @@ -55,9 +47,7 @@ - { src: "crontab.j2", dest: "crontab" } - { src: "id_rsa.j2", dest: "id_rsa" } - { src: "letsencrypt-lego-run.sh.j2", dest: "letsencrypt-lego-run.sh" } - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart letsencrypt-lego container diff --git a/ansible/roles/letsencrypt/tasks/precheck.yml b/ansible/roles/letsencrypt/tasks/precheck.yml index 6ad18cb535..ce8dac2f1f 100644 --- a/ansible/roles/letsencrypt/tasks/precheck.yml +++ b/ansible/roles/letsencrypt/tasks/precheck.yml @@ -18,8 +18,7 @@ state: stopped when: - container_facts['letsencrypt_webserver'] is not defined - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - name: Validating letsencrypt email variable run_once: true diff --git a/ansible/roles/loadbalancer/tasks/check-containers.yml b/ansible/roles/loadbalancer/tasks/check-containers.yml index bb2798739e..ee6f92fe4f 100644 --- a/ansible/roles/loadbalancer/tasks/check-containers.yml +++ b/ansible/roles/loadbalancer/tasks/check-containers.yml @@ -10,9 +10,6 @@ dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" privileged: "{{ item.value.privileged | default(False) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ loadbalancer_services }}" + with_dict: "{{ loadbalancer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/loadbalancer/tasks/config.yml b/ansible/roles/loadbalancer/tasks/config.yml index c2270cbee0..d2ca4fea10 100644 --- a/ansible/roles/loadbalancer/tasks/config.yml +++ b/ansible/roles/loadbalancer/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ loadbalancer_services }}" + with_dict: "{{ loadbalancer_services | select_services_enabled_and_mapped_to_host }}" - name: Ensuring haproxy service config subdir exists vars: @@ -22,9 +19,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Ensuring proxysql service config subdirectories exist vars: @@ -39,9 +34,7 @@ with_items: - "users" - "rules" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Ensuring keepalived checks subdir exists vars: @@ -53,9 +46,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Remove mariadb.cfg if proxysql enabled vars: @@ -65,8 +56,7 @@ state: absent become: true when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - loadbalancer_services.proxysql.enabled | bool notify: - Restart haproxy container @@ -81,12 +71,11 @@ with_dict: "{{ loadbalancer_services }}" when: - keepalived_track_script_enabled | bool - - inventory_hostname in groups[service.group] - item.key != 'keepalived' - item.key != 'haproxy-ssh' - not item.value.enabled | bool or not inventory_hostname in groups[item.value.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart keepalived container @@ -101,12 +90,11 @@ with_dict: "{{ loadbalancer_services }}" when: - keepalived_track_script_enabled | bool - - inventory_hostname in groups[service.group] - inventory_hostname in groups[item.value.group] - item.key != 'keepalived' - item.key != 'haproxy-ssh' - item.value.enabled | bool - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart keepalived container @@ -116,10 +104,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ loadbalancer_services }}" + with_dict: "{{ loadbalancer_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -131,9 +116,7 @@ dest: "{{ node_config_directory }}/haproxy/haproxy.cfg" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/haproxy/{{ inventory_hostname }}/haproxy_main.cfg" - "{{ node_custom_config }}/haproxy/haproxy_main.cfg" @@ -149,9 +132,7 @@ dest: "{{ node_config_directory }}/proxysql/proxysql.yaml" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/proxysql/{{ inventory_hostname }}/proxysql.yaml" - "{{ node_custom_config }}/proxysql/proxysql.yaml" @@ -168,8 +149,7 @@ mode: "0660" become: true when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - haproxy_single_external_frontend | bool notify: - Restart haproxy container @@ -182,9 +162,7 @@ dest: "{{ node_config_directory }}/haproxy/services.d/" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_fileglob: - "{{ node_custom_config }}/haproxy/services.d/*.cfg" notify: @@ -198,9 +176,7 @@ dest: "{{ node_config_directory }}/keepalived/keepalived.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/keepalived/{{ inventory_hostname }}/keepalived.conf" - "{{ node_custom_config }}/keepalived/keepalived.conf" @@ -220,8 +196,7 @@ - not enable_letsencrypt | bool - kolla_enable_tls_external | bool - not kolla_externally_managed_cert | bool - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host with_items: - "haproxy.pem" notify: @@ -239,8 +214,7 @@ - not enable_letsencrypt | bool - kolla_enable_tls_internal | bool - not kolla_externally_managed_cert | bool - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host with_items: - "haproxy-internal.pem" notify: @@ -258,9 +232,7 @@ dest: "{{ node_config_directory }}/haproxy/haproxy_run.sh" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/haproxy/{{ inventory_hostname }}/haproxy_run.sh" - "{{ node_custom_config }}/haproxy/haproxy_run.sh" @@ -276,9 +248,7 @@ dest: "{{ node_config_directory }}/proxysql/proxysql_run.sh" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/proxysql/{{ inventory_hostname }}/proxysql_run.sh" - "{{ node_custom_config }}/proxysql/proxysql_run.sh" @@ -288,7 +258,7 @@ - name: Copying files for haproxy-ssh vars: - haproxy_ssh: "{{ loadbalancer_services['haproxy-ssh'] }}" + service: "{{ loadbalancer_services['haproxy-ssh'] }}" template: src: "{{ item.src }}" dest: "{{ node_config_directory }}/haproxy-ssh/{{ item.dest }}" @@ -297,8 +267,6 @@ with_items: - { src: "haproxy-ssh/sshd_config.j2", dest: "sshd_config" } - { src: "haproxy-ssh/id_rsa.pub", dest: "id_rsa.pub" } - when: - - inventory_hostname in groups[haproxy_ssh.group] - - haproxy_ssh.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart haproxy-ssh container diff --git a/ansible/roles/magnum/tasks/check-containers.yml b/ansible/roles/magnum/tasks/check-containers.yml index ca50adadac..b233b5e603 100644 --- a/ansible/roles/magnum/tasks/check-containers.yml +++ b/ansible/roles/magnum/tasks/check-containers.yml @@ -10,9 +10,6 @@ dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" environment: "{{ item.value.environment }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ magnum_services }}" + with_dict: "{{ magnum_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/magnum/tasks/config.yml b/ansible/roles/magnum/tasks/config.yml index 401adec0a9..bbc01369a1 100644 --- a/ansible/roles/magnum/tasks/config.yml +++ b/ansible/roles/magnum/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ magnum_services }}" + with_dict: "{{ magnum_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -45,10 +42,8 @@ mode: "0660" become: true when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - magnum_kubeconfig_file.stat.exists - with_dict: "{{ magnum_services }}" + with_dict: "{{ magnum_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -68,10 +63,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ magnum_services }}" + with_dict: "{{ magnum_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -88,10 +80,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/magnum.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ magnum_services }}" + with_dict: "{{ magnum_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -103,8 +92,6 @@ become: true when: - magnum_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ magnum_services }}" + with_dict: "{{ magnum_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/manila/tasks/check-containers.yml b/ansible/roles/manila/tasks/check-containers.yml index 7c3091ec7b..ce52004723 100644 --- a/ansible/roles/manila/tasks/check-containers.yml +++ b/ansible/roles/manila/tasks/check-containers.yml @@ -10,9 +10,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ manila_services }}" + with_dict: "{{ manila_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/manila/tasks/config.yml b/ansible/roles/manila/tasks/config.yml index bf2929c804..ad39399142 100644 --- a/ansible/roles/manila/tasks/config.yml +++ b/ansible/roles/manila/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ manila_services }}" + with_dict: "{{ manila_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: external_ceph.yml when: @@ -46,10 +43,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ manila_services }}" + with_dict: "{{ manila_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -68,9 +62,7 @@ become: true when: - item.key in [ "manila-api", "manila-data", "manila-scheduler" ] - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ manila_services }}" + with_dict: "{{ manila_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -90,9 +82,7 @@ dest: "{{ node_config_directory }}/{{ item }}/manila.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - "manila-share" notify: @@ -105,8 +95,6 @@ mode: "0660" when: - manila_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ manila_services }}" + with_dict: "{{ manila_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/manila/tasks/external_ceph.yml b/ansible/roles/manila/tasks/external_ceph.yml index 618281f9d5..729a14769d 100644 --- a/ansible/roles/manila/tasks/external_ceph.yml +++ b/ansible/roles/manila/tasks/external_ceph.yml @@ -9,9 +9,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Copy over multiple ceph configs for Manila merge_configs: diff --git a/ansible/roles/mariadb/tasks/check-containers.yml b/ansible/roles/mariadb/tasks/check-containers.yml index e8a5b990cf..e5ff27d4e9 100644 --- a/ansible/roles/mariadb/tasks/check-containers.yml +++ b/ansible/roles/mariadb/tasks/check-containers.yml @@ -10,9 +10,6 @@ dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment | default(omit) }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ mariadb_services }}" + with_dict: "{{ mariadb_services | select_services_enabled_and_mapped_to_host }}" notify: - "restart {{ item.key }}" diff --git a/ansible/roles/mariadb/tasks/config.yml b/ansible/roles/mariadb/tasks/config.yml index fedb9b4ed2..b0691deef9 100644 --- a/ansible/roles/mariadb/tasks/config.yml +++ b/ansible/roles/mariadb/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ mariadb_services }}" + with_dict: "{{ mariadb_services | select_services_enabled_and_mapped_to_host }}" - name: Ensuring database backup config directory exists file: @@ -45,10 +42,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ mariadb_services }}" + with_dict: "{{ mariadb_services | select_services_enabled_and_mapped_to_host }}" notify: - "restart {{ item.key }}" @@ -76,8 +70,6 @@ dest: "{{ node_config_directory }}/{{ service_name }}/galera.cnf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - restart mariadb diff --git a/ansible/roles/masakari/tasks/check-containers.yml b/ansible/roles/masakari/tasks/check-containers.yml index 004a287981..fa46c70bcc 100644 --- a/ansible/roles/masakari/tasks/check-containers.yml +++ b/ansible/roles/masakari/tasks/check-containers.yml @@ -10,9 +10,6 @@ privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ masakari_services }}" + with_dict: "{{ masakari_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/masakari/tasks/config.yml b/ansible/roles/masakari/tasks/config.yml index df93a3550c..5a9e2bb4cb 100644 --- a/ansible/roles/masakari/tasks/config.yml +++ b/ansible/roles/masakari/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ masakari_services }}" + with_dict: "{{ masakari_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -39,9 +36,7 @@ become: true when: - masakari_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ masakari_services }}" + with_dict: "{{ masakari_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -51,10 +46,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ masakari_services }}" + with_dict: "{{ masakari_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -76,9 +68,7 @@ dest: "{{ node_config_directory }}/{{ service_name }}/masakari.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - masakari-api - masakari-engine @@ -99,9 +89,7 @@ dest: "{{ node_config_directory }}/{{ service_name }}/masakari-monitors.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - masakari-instancemonitor - masakari-hostmonitor @@ -116,9 +104,7 @@ dest: "{{ node_config_directory }}/masakari-api/wsgi-masakari.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart masakari-api container @@ -132,9 +118,7 @@ dest: "{{ node_config_directory }}/masakari-api/masakari-api-paste.ini" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart masakari-api container @@ -149,8 +133,7 @@ mode: "0660" when: - libvirt_enable_sasl | bool - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host with_items: - { src: "auth.conf.j2", dest: "auth.conf", service: "masakari-instancemonitor" } notify: diff --git a/ansible/roles/memcached/tasks/check-containers.yml b/ansible/roles/memcached/tasks/check-containers.yml index 120b3ecee1..49d1c29537 100644 --- a/ansible/roles/memcached/tasks/check-containers.yml +++ b/ansible/roles/memcached/tasks/check-containers.yml @@ -11,7 +11,5 @@ volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" healthcheck: "{{ service.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: Restart memcached container diff --git a/ansible/roles/memcached/tasks/config.yml b/ansible/roles/memcached/tasks/config.yml index 20edb14162..3287a3f47e 100644 --- a/ansible/roles/memcached/tasks/config.yml +++ b/ansible/roles/memcached/tasks/config.yml @@ -20,7 +20,5 @@ become: true with_items: - "memcached" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: Restart memcached container diff --git a/ansible/roles/mistral/tasks/check-containers.yml b/ansible/roles/mistral/tasks/check-containers.yml index 81ba36d15d..7ed520ca3d 100644 --- a/ansible/roles/mistral/tasks/check-containers.yml +++ b/ansible/roles/mistral/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ mistral_services }}" + with_dict: "{{ mistral_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/mistral/tasks/config.yml b/ansible/roles/mistral/tasks/config.yml index 3f30bb675a..604c5f107c 100644 --- a/ansible/roles/mistral/tasks/config.yml +++ b/ansible/roles/mistral/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ mistral_services }}" + with_dict: "{{ mistral_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ mistral_services }}" + with_dict: "{{ mistral_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -61,10 +55,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/mistral.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ mistral_services }}" + with_dict: "{{ mistral_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -76,9 +67,7 @@ become: true when: - mistral_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ mistral_services }}" + with_dict: "{{ mistral_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -90,9 +79,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/mistral-event-engine/event_definitions.yaml" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/mistral/{{ inventory_hostname }}/event_definitions.yaml" - "{{ node_custom_config }}/mistral/event_definitions.yaml" diff --git a/ansible/roles/multipathd/tasks/check-containers.yml b/ansible/roles/multipathd/tasks/check-containers.yml index fe82a085fc..5d41bdba5c 100644 --- a/ansible/roles/multipathd/tasks/check-containers.yml +++ b/ansible/roles/multipathd/tasks/check-containers.yml @@ -9,9 +9,6 @@ ipc_mode: "{{ item.value.ipc_mode }}" privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ multipathd_services }}" + with_dict: "{{ multipathd_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/multipathd/tasks/config.yml b/ansible/roles/multipathd/tasks/config.yml index f9281e9f8e..9c75e93d6e 100644 --- a/ansible/roles/multipathd/tasks/config.yml +++ b/ansible/roles/multipathd/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ multipathd_services }}" + with_dict: "{{ multipathd_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -18,10 +15,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ multipathd_services }}" + with_dict: "{{ multipathd_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart multipathd container @@ -37,8 +31,6 @@ - "{{ node_custom_config }}/multipath/{{ inventory_hostname }}/multipath.conf" - "{{ node_custom_config }}/multipath.conf" - "multipath.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart multipathd container diff --git a/ansible/roles/neutron/tasks/check-containers.yml b/ansible/roles/neutron/tasks/check-containers.yml index 42bfb1fcc8..cc3ec4fa8e 100644 --- a/ansible/roles/neutron/tasks/check-containers.yml +++ b/ansible/roles/neutron/tasks/check-containers.yml @@ -11,9 +11,6 @@ dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment | default(omit) }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/neutron/tasks/config-host.yml b/ansible/roles/neutron/tasks/config-host.yml index 5983d11a2e..a33919b123 100644 --- a/ansible/roles/neutron/tasks/config-host.yml +++ b/ansible/roles/neutron/tasks/config-host.yml @@ -21,7 +21,7 @@ include_role: name: sysctl vars: - neutron_l3_agent: "{{ neutron_services['neutron-l3-agent'] }}" + service: "{{ neutron_services['neutron-l3-agent'] }}" settings: - { name: "net.ipv4.neigh.default.gc_thresh1", value: "{{ neutron_l3_agent_host_ipv4_neigh_gc_thresh1 }}"} - { name: "net.ipv4.neigh.default.gc_thresh2", value: "{{ neutron_l3_agent_host_ipv4_neigh_gc_thresh2 }}"} @@ -31,4 +31,4 @@ - { name: "net.ipv6.neigh.default.gc_thresh3", value: "{{ neutron_l3_agent_host_ipv6_neigh_gc_thresh3 }}"} when: - set_sysctl | bool - - (neutron_l3_agent.enabled | bool and neutron_l3_agent.host_in_groups | bool) + - service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/neutron/tasks/config.yml b/ansible/roles/neutron/tasks/config.yml index ef5055e378..8ba4e88a74 100644 --- a/ansible/roles/neutron/tasks/config.yml +++ b/ansible/roles/neutron/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" - name: Check if extra ml2 plugins exists find: @@ -26,7 +23,7 @@ - name: Creating TLS backend PEM File vars: - neutron_tls_proxy: "{{ neutron_services['neutron-tls-proxy'] }}" + service: "{{ neutron_services['neutron-tls-proxy'] }}" assemble: src: "{{ node_config_directory }}/neutron-tls-proxy/" dest: "{{ node_config_directory }}/neutron-tls-proxy/neutron-cert-and-key.pem" @@ -34,9 +31,7 @@ regexp: "^neutron-(cert|key)\\.pem$" remote_src: true become: true - when: - - neutron_tls_proxy.enabled | bool - - neutron_tls_proxy.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host - name: Check if policies shall be overwritten stat: @@ -65,9 +60,7 @@ become: true when: - neutron_policy_file is defined - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -77,10 +70,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -114,10 +104,8 @@ dest: "{{ node_config_directory }}/{{ item.key }}/neutron.conf" mode: "0660" when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - item.key in services_need_neutron_conf - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -136,24 +124,20 @@ dest: "{{ node_config_directory }}/{{ item.key }}/neutron_vpnaas.conf" mode: "0660" when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - item.key in services_need_neutron_vpnaas_conf - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" - name: Copying over ssh key become: true vars: - neutron_server: "{{ neutron_services['neutron-server'] }}" + service: "{{ neutron_services['neutron-server'] }}" template: src: "id_rsa" dest: "{{ node_config_directory }}/neutron-server/id_rsa" mode: 0600 - when: - - neutron_server.enabled | bool - - neutron_server.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host - name: Copying over ml2_conf.ini become: true @@ -171,9 +155,7 @@ mode: "0660" when: - item.key in services_need_ml2_conf_ini - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -181,6 +163,7 @@ become: true vars: service_name: "neutron-linuxbridge-agent" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/linuxbridge_agent.ini.j2" @@ -188,9 +171,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/linuxbridge_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/linuxbridge_agent.ini" mode: "0660" - when: - - neutron_services[service_name].enabled | bool - - neutron_services[service_name].host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -198,6 +179,7 @@ become: true vars: service_name: "neutron-openvswitch-agent" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/openvswitch_agent.ini.j2" @@ -205,9 +187,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/openvswitch_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/openvswitch_agent.ini" mode: "0660" - when: - - neutron_services[service_name].enabled | bool - - neutron_services[service_name].host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -215,7 +195,7 @@ become: true vars: service_name: "neutron-sriov-agent" - neutron_sriov_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/sriov_agent.ini.j2" @@ -223,9 +203,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/sriov_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/sriov_agent.ini" mode: "0660" - when: - - neutron_sriov_agent.enabled | bool - - neutron_sriov_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -233,7 +211,7 @@ become: true vars: service_name: "neutron-mlnx-agent" - neutron_mlnx_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/mlnx_agent.ini.j2" @@ -241,9 +219,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/mlnx_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/mlnx_agent.ini" mode: "0660" - when: - - neutron_mlnx_agent.enabled | bool - - neutron_mlnx_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -251,7 +227,7 @@ become: true vars: service_name: "neutron-eswitchd" - neutron_eswitchd: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/eswitchd.conf.j2" @@ -259,9 +235,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/eswitchd.conf" dest: "{{ node_config_directory }}/{{ service_name }}/eswitchd.conf" mode: "0660" - when: - - neutron_eswitchd.enabled | bool - - neutron_eswitchd.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -269,7 +243,7 @@ become: true vars: service_name: "neutron-dhcp-agent" - neutron_dhcp_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/dhcp_agent.ini.j2" @@ -277,9 +251,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/dhcp_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/dhcp_agent.ini" mode: "0660" - when: - - neutron_dhcp_agent.enabled | bool - - neutron_dhcp_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -287,7 +259,7 @@ become: true vars: service_name: "neutron-dhcp-agent" - neutron_dhcp_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/{{ service_name }}/dnsmasq.conf" @@ -296,9 +268,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/dnsmasq.conf" - "{{ node_custom_config }}/neutron/dnsmasq.conf" - "dnsmasq.conf.j2" - when: - - neutron_dhcp_agent.enabled | bool - - neutron_dhcp_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -317,9 +287,7 @@ mode: "0660" when: - item.key in services_need_l3_agent_ini - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -339,9 +307,7 @@ when: - enable_neutron_fwaas | bool - item.key in services_need_fwaas_driver_ini - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -349,16 +315,14 @@ become: true vars: service_name: "neutron-metadata-agent" - neutron_metadata_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/metadata_agent.ini.j2" - "{{ node_custom_config }}/neutron/metadata_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/metadata_agent.ini" mode: "0660" - when: - - neutron_metadata_agent.enabled | bool - - neutron_metadata_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -366,16 +330,14 @@ become: true vars: service_name: "neutron-ovn-metadata-agent" - neutron_ovn_metadata_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/neutron_ovn_metadata_agent.ini.j2" - "{{ node_custom_config }}/neutron/neutron_ovn_metadata_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/neutron_ovn_metadata_agent.ini" mode: "0660" - when: - - neutron_ovn_metadata_agent.enabled | bool - - neutron_ovn_metadata_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -383,16 +345,14 @@ become: true vars: service_name: "neutron-metering-agent" - neutron_metering_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/metering_agent.ini.j2" - "{{ node_custom_config }}/neutron/metering_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/metering_agent.ini" mode: "0660" - when: - - neutron_metering_agent.enabled | bool - - neutron_metering_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -400,16 +360,14 @@ become: true vars: service_name: "ironic-neutron-agent" - ironic_neutron_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/ironic_neutron_agent.ini.j2" - "{{ node_custom_config }}/neutron/ironic_neutron_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/ironic_neutron_agent.ini" mode: "0660" - when: - - ironic_neutron_agent.enabled | bool - - ironic_neutron_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -417,16 +375,14 @@ become: true vars: service_name: "neutron-bgp-dragent" - neutron_bgp_dragent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/bgp_dragent.ini.j2" - "{{ node_custom_config }}/neutron/bgp_dragent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/bgp_dragent.ini" mode: "0660" - when: - - neutron_bgp_dragent.enabled | bool - - neutron_bgp_dragent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -434,16 +390,14 @@ become: true vars: service_name: "neutron-ovn-agent" - neutron_ovn_agent: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/ovn_agent.ini.j2" - "{{ node_custom_config }}/neutron/ovn_agent.ini" dest: "{{ node_config_directory }}/{{ service_name }}/ovn_agent.ini" mode: "0660" - when: - - neutron_ovn_agent.enabled | bool - - neutron_ovn_agent.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -451,7 +405,7 @@ become: true vars: service_name: "neutron-server" - neutron_server: "{{ neutron_services[service_name] }}" + service: "{{ neutron_services[service_name] }}" merge_configs: sources: - "{{ role_path }}/templates/nsx.ini.j2" @@ -460,8 +414,7 @@ dest: "{{ node_config_directory }}/{{ service_name }}/nsx.ini" mode: "0660" when: - - neutron_server.enabled | bool - - neutron_server.host_in_groups | bool + - service | service_enabled_and_mapped_to_host - neutron_plugin_agent in ['vmware_nsxv', 'vmware_nsxv3', 'vmware_nsxp', 'vmware_dvs'] notify: - "Restart {{ service_name }} container" @@ -475,9 +428,7 @@ src: neutron-l3-agent-wrapper.sh.j2 dest: "{{ node_config_directory }}/{{ service_name }}/neutron-l3-agent-wrapper.sh" mode: "0770" - when: - - service.enabled | bool - - service.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart {{ service_name }} container" @@ -506,7 +457,7 @@ - name: Copying over neutron-tls-proxy.cfg vars: - neutron_tls_proxy: "{{ neutron_services['neutron-tls-proxy'] }}" + service: "{{ neutron_services['neutron-tls-proxy'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/neutron-tls-proxy/neutron-tls-proxy.cfg" @@ -516,9 +467,7 @@ - "{{ node_custom_config }}/neutron/{{ inventory_hostname }}/neutron-tls-proxy.cfg" - "{{ node_custom_config }}/neutron/neutron-tls-proxy.cfg" - "neutron-tls-proxy.cfg.j2" - when: - - neutron_tls_proxy.enabled | bool - - neutron_tls_proxy.host_in_groups | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart neutron-tls-proxy container @@ -538,9 +487,7 @@ mode: "0660" when: - enable_neutron_taas | bool - - item.value.enabled | bool - - item.value.host_in_groups | bool - item.key in services_need_neutron_taas_conf - with_dict: "{{ neutron_services }}" + with_dict: "{{ neutron_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/neutron/tasks/rolling_upgrade.yml b/ansible/roles/neutron/tasks/rolling_upgrade.yml index e5fb3a53fe..d0a98f94ad 100644 --- a/ansible/roles/neutron/tasks/rolling_upgrade.yml +++ b/ansible/roles/neutron/tasks/rolling_upgrade.yml @@ -45,8 +45,8 @@ - name: Stopping all neutron-server for contract db vars: - neutron_server: "{{ neutron_services['neutron-server'] }}" - first_neutron_server_host: "{{ groups[neutron_server.group][0] }}" + service: "{{ neutron_services['neutron-server'] }}" + first_neutron_server_host: "{{ groups[service.group][0] }}" results_of_check_pending_contract_scripts: "{{ hostvars[first_neutron_server_host]['neutron_check_contract_db_stdout'] }}" # NOTE(hrw): no idea filter_rc: "results[?rc!=`0`]" @@ -55,9 +55,9 @@ kolla_container: action: "stop_container" common_options: "{{ docker_common_options }}" - name: "{{ neutron_server.container_name }}" + name: "{{ service.container_name }}" when: - - neutron_server.host_in_groups | bool + - service.host_in_groups | bool - is_stop_neutron_server | length > 0 notify: - "Restart neutron-server container" diff --git a/ansible/roles/nova-cell/tasks/check-containers.yml b/ansible/roles/nova-cell/tasks/check-containers.yml index 4860124e1a..93452874a6 100644 --- a/ansible/roles/nova-cell/tasks/check-containers.yml +++ b/ansible/roles/nova-cell/tasks/check-containers.yml @@ -14,9 +14,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ nova_cell_services }}" + with_dict: "{{ nova_cell_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/nova-cell/tasks/config-libvirt-tls.yml b/ansible/roles/nova-cell/tasks/config-libvirt-tls.yml index d8a1d94421..0e1891c41a 100644 --- a/ansible/roles/nova-cell/tasks/config-libvirt-tls.yml +++ b/ansible/roles/nova-cell/tasks/config-libvirt-tls.yml @@ -1,46 +1,29 @@ --- -- name: Copying over libvirt TLS keys (nova-libvirt) +- name: Copying over libvirt TLS keys to services become: true vars: - service: "{{ nova_cell_services['nova-libvirt'] }}" - service_name: nova-libvirt + services: + - "nova-compute" + - "nova-libvirt" + key_files: + - cacert.pem + - clientcert.pem + - clientkey.pem + - servercert.pem + - serverkey.pem + service_name: "{{ item[0] }}" + filename: "{{ item[1] }}" paths: - - "{{ node_custom_config }}/nova/nova-libvirt/{{ inventory_hostname }}/{{ item }}" - - "{{ node_custom_config }}/nova/nova-libvirt/{{ item }}" + - "{{ node_custom_config }}/nova/nova-libvirt/{{ inventory_hostname }}/{{ filename }}" + - "{{ node_custom_config }}/nova/nova-libvirt/{{ filename }}" + service: "{{ nova_cell_services[service_name] }}" copy: src: "{{ lookup('first_found', paths) }}" - dest: "{{ node_config_directory }}/{{ service_name }}/{{ item }}" + dest: "{{ node_config_directory }}/{{ service_name }}/{{ filename }}" mode: "0600" when: - - inventory_hostname in groups[service.group] - - service.enabled | bool - with_items: - - cacert.pem - - servercert.pem - - serverkey.pem - - clientcert.pem - - clientkey.pem + - service | service_enabled_and_mapped_to_host + - not (service_name == 'nova-compute' and (filename == 'servercert.pem' or filename == 'serverkey.pem')) + loop: "{{ services | product(key_files) | list }}" notify: - - Restart {{ service_name }} container - -- name: Copying over libvirt TLS keys (nova-compute) - become: true - vars: - service: "{{ nova_cell_services['nova-compute'] }}" - service_name: nova-compute - paths: - - "{{ node_custom_config }}/nova/nova-libvirt/{{ inventory_hostname }}/{{ item }}" - - "{{ node_custom_config }}/nova/nova-libvirt/{{ item }}" - copy: - src: "{{ lookup('first_found', paths) }}" - dest: "{{ node_config_directory }}/{{ service_name }}/{{ item }}" - mode: "0600" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool - with_items: - - cacert.pem - - clientcert.pem - - clientkey.pem - notify: - - Restart {{ service_name }} container + - Restart {{service_name }} container diff --git a/ansible/roles/nova-cell/tasks/config.yml b/ansible/roles/nova-cell/tasks/config.yml index 1618652bfa..a4e937b3b2 100644 --- a/ansible/roles/nova-cell/tasks/config.yml +++ b/ansible/roles/nova-cell/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ nova_cell_services }}" + with_dict: "{{ nova_cell_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: copy-certs.yml when: @@ -59,10 +56,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ nova_cell_services }}" + with_dict: "{{ nova_cell_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -81,10 +75,8 @@ dest: "{{ node_config_directory }}/{{ item.key }}/nova.conf" mode: "0660" when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - item.key in nova_cell_services_require_nova_conf - with_dict: "{{ nova_cell_services }}" + with_dict: "{{ nova_cell_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -97,9 +89,8 @@ dest: "{{ node_config_directory }}/nova-compute/provider_config.yaml" mode: "0660" when: - - inventory_hostname in groups[service.group] + - service | service_enabled_and_mapped_to_host - nova_cell_compute_provider_config is defined - - service.enabled | bool notify: - Restart nova-compute container @@ -111,9 +102,7 @@ src: "{{ item.src }}" dest: "{{ node_config_directory }}/nova-libvirt/{{ item.dest }}" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - { src: "qemu.conf.j2", dest: "qemu.conf" } - { src: "libvirtd.conf.j2", dest: "libvirtd.conf" } @@ -138,8 +127,7 @@ mode: "0660" when: - libvirt_enable_sasl | bool - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host with_items: - { src: "auth.conf.j2", dest: "auth.conf", service: "nova-compute" } - { src: "auth.conf.j2", dest: "auth.conf", service: "nova-libvirt" } @@ -155,9 +143,7 @@ src: "{{ item.src }}" dest: "{{ node_config_directory }}/nova-ssh/{{ item.dest }}" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - { src: "sshd_config.j2", dest: "sshd_config" } - { src: "id_rsa", dest: "id_rsa" } @@ -176,8 +162,7 @@ when: - nova_compute_virt_type == "vmware" - not vmware_vcenter_insecure | bool - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - Restart nova-compute container @@ -194,9 +179,7 @@ - "{{ node_custom_config }}/nova_compute/release" - "{{ node_custom_config }}/nova/release" skip: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart nova-compute container @@ -209,9 +192,7 @@ dest: "{{ node_config_directory }}/nova-compute/hostnqn" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart nova-compute container @@ -222,11 +203,9 @@ dest: "{{ node_config_directory }}/{{ item.key }}/{{ nova_policy_file }}" mode: "0660" when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - nova_policy_file is defined - item.key in nova_cell_services_require_policy_json - with_dict: "{{ nova_cell_services }}" + with_dict: "{{ nova_cell_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -240,8 +219,7 @@ become: True when: - vendordata_file_path is defined - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - "Restart {{ item }} container" with_items: diff --git a/ansible/roles/nova-cell/tasks/external_ceph.yml b/ansible/roles/nova-cell/tasks/external_ceph.yml index b1b0d2ca0b..332e700206 100644 --- a/ansible/roles/nova-cell/tasks/external_ceph.yml +++ b/ansible/roles/nova-cell/tasks/external_ceph.yml @@ -98,8 +98,7 @@ - nova-compute - nova-libvirt when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - nova_backend == "rbd" notify: - Restart {{ item }} container @@ -146,8 +145,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[service.group] + when: service | service_enabled_and_mapped_to_host - name: Pushing nova secret xml for libvirt vars: @@ -159,9 +157,7 @@ group: "{{ config_owner_group }}" mode: "0600" become: true - when: - - inventory_hostname in groups[service.group] - - item.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: - uuid: "{{ rbd_secret_uuid }}" name: "client.nova secret" @@ -182,7 +178,7 @@ mode: "0600" become: true when: - - inventory_hostname in groups[service.group] + - service | service_enabled_and_mapped_to_host - item.enabled | bool - external_ceph_cephx_enabled | bool with_items: diff --git a/ansible/roles/nova-cell/tasks/precheck.yml b/ansible/roles/nova-cell/tasks/precheck.yml index dcb11eadef..efa19fdd8b 100644 --- a/ansible/roles/nova-cell/tasks/precheck.yml +++ b/ansible/roles/nova-cell/tasks/precheck.yml @@ -30,7 +30,7 @@ - name: Checking free port for Nova NoVNC Proxy vars: - nova_novncproxy: "{{ nova_cell_services['nova-novncproxy'] }}" + service: "{{ nova_cell_services['nova-novncproxy'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ nova_novncproxy_listen_port }}" @@ -39,12 +39,11 @@ state: stopped when: - container_facts['nova_novncproxy'] is not defined - - nova_novncproxy.enabled | bool - - inventory_hostname in groups[nova_novncproxy.group] + - service | service_enabled_and_mapped_to_host - name: Checking free port for Nova Serial Proxy vars: - nova_serialproxy: "{{ nova_cell_services['nova-serialproxy'] }}" + service: "{{ nova_cell_services['nova-serialproxy'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ nova_serialproxy_listen_port }}" @@ -53,12 +52,11 @@ state: stopped when: - container_facts['nova_serialproxy'] is not defined - - nova_serialproxy.enabled | bool - - inventory_hostname in groups[nova_serialproxy.group] + - service | service_enabled_and_mapped_to_host - name: Checking free port for Nova Spice HTML5 Proxy vars: - nova_spicehtml5proxy: "{{ nova_cell_services['nova-spicehtml5proxy'] }}" + service: "{{ nova_cell_services['nova-spicehtml5proxy'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ nova_spicehtml5proxy_listen_port }}" @@ -67,12 +65,11 @@ state: stopped when: - container_facts['nova_spicehtml5proxy'] is not defined - - nova_spicehtml5proxy.enabled | bool - - inventory_hostname in groups[nova_spicehtml5proxy.group] + - service | service_enabled_and_mapped_to_host - name: Checking free port for Nova SSH (API interface) vars: - nova_ssh: "{{ nova_cell_services['nova-ssh'] }}" + service: "{{ nova_cell_services['nova-ssh'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ nova_ssh_port }}" @@ -81,12 +78,11 @@ state: stopped when: - container_facts['nova_ssh'] is not defined - - nova_ssh.enabled | bool - - inventory_hostname in groups[nova_ssh.group] + - service | service_enabled_and_mapped_to_host - name: Checking free port for Nova SSH (migration interface) vars: - nova_ssh: "{{ nova_cell_services['nova-ssh'] }}" + service: "{{ nova_cell_services['nova-ssh'] }}" wait_for: host: "{{ migration_interface_address }}" port: "{{ nova_ssh_port }}" @@ -96,12 +92,11 @@ when: - migration_interface_address != api_interface_address - container_facts['nova_ssh'] is not defined - - nova_ssh.enabled | bool - - inventory_hostname in groups[nova_ssh.group] + - service | service_enabled_and_mapped_to_host - name: Checking free port for Nova Libvirt vars: - nova_libvirt: "{{ nova_cell_services['nova-libvirt'] }}" + service: "{{ nova_cell_services['nova-libvirt'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ nova_libvirt_port }}" @@ -110,19 +105,17 @@ state: stopped when: - container_facts['nova_libvirt'] is not defined - - nova_libvirt.enabled | bool - - inventory_hostname in groups[nova_libvirt.group] + - service | service_enabled_and_mapped_to_host - name: Checking that host libvirt is not running vars: - nova_libvirt: "{{ nova_cell_services['nova-libvirt'] }}" + service: "{{ nova_cell_services['nova-libvirt'] }}" stat: path=/var/run/libvirt/libvirt-sock register: result failed_when: result.stat.exists when: - container_facts['nova_libvirt'] is not defined - - nova_libvirt.enabled | bool - - inventory_hostname in groups[nova_libvirt.group] + - service | service_enabled_and_mapped_to_host - name: Checking that nova_libvirt container is not running vars: diff --git a/ansible/roles/nova-cell/tasks/reload.yml b/ansible/roles/nova-cell/tasks/reload.yml index 7f61efb302..5724effdf2 100644 --- a/ansible/roles/nova-cell/tasks/reload.yml +++ b/ansible/roles/nova-cell/tasks/reload.yml @@ -36,6 +36,5 @@ healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action == 'upgrade' - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host with_items: "{{ nova_cell_services_require_nova_conf }}" diff --git a/ansible/roles/nova-cell/tasks/upgrade.yml b/ansible/roles/nova-cell/tasks/upgrade.yml index 46926af6c9..b9a8c3556b 100644 --- a/ansible/roles/nova-cell/tasks/upgrade.yml +++ b/ansible/roles/nova-cell/tasks/upgrade.yml @@ -5,12 +5,10 @@ action: "stop_container" common_options: "{{ docker_common_options }}" name: "{{ item.value.container_name }}" - with_dict: "{{ nova_cell_services }}" + with_dict: "{{ nova_cell_services | select_services_enabled_and_mapped_to_host }}" when: - "'nova-compute' not in item.key" - item.key in nova_cell_services_require_nova_conf - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - nova_safety_upgrade | bool - import_tasks: rolling_upgrade.yml diff --git a/ansible/roles/nova/tasks/check-containers.yml b/ansible/roles/nova/tasks/check-containers.yml index b03d89e676..f1b6e1817c 100644 --- a/ansible/roles/nova/tasks/check-containers.yml +++ b/ansible/roles/nova/tasks/check-containers.yml @@ -13,9 +13,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ nova_services }}" + with_dict: "{{ nova_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/nova/tasks/config.yml b/ansible/roles/nova/tasks/config.yml index 48094c3f96..8e53d79f71 100644 --- a/ansible/roles/nova/tasks/config.yml +++ b/ansible/roles/nova/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ nova_services }}" + with_dict: "{{ nova_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -54,10 +51,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ nova_services }}" + with_dict: "{{ nova_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -74,10 +68,7 @@ - "{{ node_custom_config }}/nova/{{ inventory_hostname }}/nova.conf" dest: "{{ node_config_directory }}/{{ item.key }}/nova.conf" mode: "0660" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ nova_services }}" + with_dict: "{{ nova_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -88,23 +79,21 @@ dest: "{{ node_config_directory }}/{{ item.key }}/{{ nova_policy_file }}" mode: "0660" when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - nova_policy_file is defined - item.key in nova_services_require_policy_json - with_dict: "{{ nova_services }}" + with_dict: "{{ nova_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" - name: Copying over nova-api-wsgi.conf + vars: + service: "{{ nova_services['nova-api'] }}" template: src: "nova-api-wsgi.conf.j2" dest: "{{ node_config_directory }}/nova-api/nova-api-wsgi.conf" mode: "0660" become: true - when: - - inventory_hostname in groups["nova-api"] - - nova_services["nova-api"].enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - "Restart nova-api container" @@ -118,7 +107,6 @@ become: True when: - vendordata_file_path is defined - - inventory_hostname in groups[service['group']] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host notify: - "Restart nova-api container" diff --git a/ansible/roles/nova/tasks/precheck.yml b/ansible/roles/nova/tasks/precheck.yml index b09fbfdd94..c1d816eb0b 100644 --- a/ansible/roles/nova/tasks/precheck.yml +++ b/ansible/roles/nova/tasks/precheck.yml @@ -16,7 +16,7 @@ - name: Checking free port for Nova API vars: - nova_api: "{{ nova_services['nova-api'] }}" + service: "{{ nova_services['nova-api'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ nova_api_listen_port }}" @@ -25,12 +25,11 @@ state: stopped when: - container_facts['nova_api'] is not defined - - inventory_hostname in groups[nova_api.group] - - nova_api.enabled | bool + - service | service_enabled_and_mapped_to_host - name: Checking free port for Nova Metadata vars: - nova_api: "{{ nova_services['nova-api'] }}" + service: "{{ nova_services['nova-api'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ nova_metadata_listen_port }}" @@ -39,5 +38,4 @@ state: stopped when: - container_facts['nova_api'] is not defined - - inventory_hostname in groups[nova_api.group] - - nova_api.enabled | bool + - service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/nova/tasks/reload_api.yml b/ansible/roles/nova/tasks/reload_api.yml index f1813edecc..10111dcdff 100644 --- a/ansible/roles/nova/tasks/reload_api.yml +++ b/ansible/roles/nova/tasks/reload_api.yml @@ -17,8 +17,7 @@ healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action == 'upgrade' - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host with_items: - nova-scheduler - nova-api diff --git a/ansible/roles/nova/tasks/reload_super_conductor.yml b/ansible/roles/nova/tasks/reload_super_conductor.yml index e9b10b9a9d..58fe18aacd 100644 --- a/ansible/roles/nova/tasks/reload_super_conductor.yml +++ b/ansible/roles/nova/tasks/reload_super_conductor.yml @@ -17,5 +17,4 @@ healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action == 'upgrade' - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/nova/tasks/upgrade.yml b/ansible/roles/nova/tasks/upgrade.yml index f60489f4a0..b70c77d572 100644 --- a/ansible/roles/nova/tasks/upgrade.yml +++ b/ansible/roles/nova/tasks/upgrade.yml @@ -44,10 +44,8 @@ action: "stop_container" common_options: "{{ docker_common_options }}" name: "{{ item.value.container_name }}" - with_dict: "{{ nova_services }}" + with_dict: "{{ nova_services | select_services_enabled_and_mapped_to_host }}" when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - nova_safety_upgrade | bool - import_tasks: rolling_upgrade.yml diff --git a/ansible/roles/octavia/tasks/check-containers.yml b/ansible/roles/octavia/tasks/check-containers.yml index a290165114..ac4244ed69 100644 --- a/ansible/roles/octavia/tasks/check-containers.yml +++ b/ansible/roles/octavia/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ octavia_services }}" + with_dict: "{{ octavia_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/octavia/tasks/config.yml b/ansible/roles/octavia/tasks/config.yml index ae370541f8..48044bc58d 100644 --- a/ansible/roles/octavia/tasks/config.yml +++ b/ansible/roles/octavia/tasks/config.yml @@ -10,10 +10,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ octavia_services }}" + with_dict: "{{ octavia_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -42,9 +39,7 @@ become: true when: - octavia_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ octavia_services }}" + with_dict: "{{ octavia_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -58,10 +53,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ octavia_services }}" + with_dict: "{{ octavia_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -77,9 +69,7 @@ - "{{ node_custom_config }}/octavia/{{ inventory_hostname }}/octavia-wsgi.conf" - "{{ node_custom_config }}/octavia/octavia-wsgi.conf" - "octavia-wsgi.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart octavia-api container @@ -96,10 +86,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/octavia.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ octavia_services }}" + with_dict: "{{ octavia_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -125,9 +112,7 @@ dest: "{{ node_config_directory }}/octavia-worker/{{ item }}" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: "{{ octavia_amphora_keys }}" notify: - Restart octavia-worker container @@ -140,9 +125,7 @@ dest: "{{ node_config_directory }}/octavia-housekeeping/{{ item }}" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: "{{ octavia_amphora_keys }}" notify: - Restart octavia-housekeeping container @@ -155,9 +138,7 @@ dest: "{{ node_config_directory }}/octavia-health-manager/{{ item }}" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_items: "{{ octavia_amphora_keys }}" notify: - Restart octavia-health-manager container diff --git a/ansible/roles/opensearch/tasks/check-containers.yml b/ansible/roles/opensearch/tasks/check-containers.yml index a8466feb6f..44f7253c26 100644 --- a/ansible/roles/opensearch/tasks/check-containers.yml +++ b/ansible/roles/opensearch/tasks/check-containers.yml @@ -10,9 +10,6 @@ name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ opensearch_services }}" + with_dict: "{{ opensearch_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/opensearch/tasks/config.yml b/ansible/roles/opensearch/tasks/config.yml index afaecb1d75..df0c9524f8 100644 --- a/ansible/roles/opensearch/tasks/config.yml +++ b/ansible/roles/opensearch/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ opensearch_services }}" + with_dict: "{{ opensearch_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: copy-certs.yml when: @@ -22,14 +19,13 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ opensearch_services }}" + with_dict: "{{ opensearch_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container - name: Copying over opensearch service config file + vars: + service: "{{ opensearch_services['opensearch'] }}" merge_yaml: sources: - "{{ role_path }}/templates/opensearch.yml.j2" @@ -39,15 +35,13 @@ dest: "{{ node_config_directory }}/opensearch/opensearch.yml" mode: "0660" become: true - when: - - inventory_hostname in groups['opensearch'] - - opensearch_services['opensearch'].enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart opensearch container - name: Copying over opensearch-dashboards config file vars: - opensearch_dashboards: "{{ opensearch_services['opensearch-dashboards'] }}" + service: "{{ opensearch_services['opensearch-dashboards'] }}" merge_yaml: sources: - "{{ role_path }}/templates/opensearch_dashboards.yml.j2" @@ -56,8 +50,6 @@ dest: "{{ node_config_directory }}/opensearch-dashboards/opensearch_dashboards.yml" mode: "0660" become: true - when: - - inventory_hostname in groups['opensearch-dashboards'] - - opensearch_dashboards.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart opensearch-dashboards container diff --git a/ansible/roles/openvswitch/tasks/check-containers.yml b/ansible/roles/openvswitch/tasks/check-containers.yml index 406ed11a20..d030119b11 100644 --- a/ansible/roles/openvswitch/tasks/check-containers.yml +++ b/ansible/roles/openvswitch/tasks/check-containers.yml @@ -10,9 +10,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck }}" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ openvswitch_services }}" + with_dict: "{{ openvswitch_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/openvswitch/tasks/config.yml b/ansible/roles/openvswitch/tasks/config.yml index 6f622e652c..29ec1a2db6 100644 --- a/ansible/roles/openvswitch/tasks/config.yml +++ b/ansible/roles/openvswitch/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ openvswitch_services }}" + with_dict: "{{ openvswitch_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services become: true @@ -18,10 +15,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ openvswitch_services }}" + with_dict: "{{ openvswitch_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -34,6 +28,5 @@ mode: "0755" become: true when: - - service.host_in_groups | bool - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - openvswitch_ovs_vsctl_wrapper_enabled | bool diff --git a/ansible/roles/openvswitch/tasks/precheck.yml b/ansible/roles/openvswitch/tasks/precheck.yml index b3d411e96c..8cc4aec449 100644 --- a/ansible/roles/openvswitch/tasks/precheck.yml +++ b/ansible/roles/openvswitch/tasks/precheck.yml @@ -16,7 +16,7 @@ - name: Checking free port for OVSDB vars: - openvswitch_db: "{{ openvswitch_services['openvswitch-db-server'] }}" + service: "{{ openvswitch_services['openvswitch-db-server'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ ovsdb_port }}" @@ -25,5 +25,4 @@ state: stopped when: - container_facts['openvswitch_db'] is not defined - - inventory_hostname in groups[openvswitch_db.group] - - openvswitch_db.enabled | bool + - service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/ovn-controller/tasks/check-containers.yml b/ansible/roles/ovn-controller/tasks/check-containers.yml index 86bbf42359..1cd016795a 100644 --- a/ansible/roles/ovn-controller/tasks/check-containers.yml +++ b/ansible/roles/ovn-controller/tasks/check-containers.yml @@ -8,9 +8,6 @@ image: "{{ item.value.image }}" volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ovn_controller_services }}" + with_dict: "{{ ovn_controller_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/ovn-controller/tasks/config.yml b/ansible/roles/ovn-controller/tasks/config.yml index fa4617efea..62a37a9452 100644 --- a/ansible/roles/ovn-controller/tasks/config.yml +++ b/ansible/roles/ovn-controller/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ovn_controller_services }}" + with_dict: "{{ ovn_controller_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -18,9 +15,6 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ovn_controller_services }}" + with_dict: "{{ ovn_controller_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/ovn-db/tasks/check-containers.yml b/ansible/roles/ovn-db/tasks/check-containers.yml index 9c298a4fff..1943282313 100644 --- a/ansible/roles/ovn-db/tasks/check-containers.yml +++ b/ansible/roles/ovn-db/tasks/check-containers.yml @@ -8,9 +8,6 @@ image: "{{ item.value.image }}" volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ovn_db_services }}" + with_dict: "{{ ovn_db_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/ovn-db/tasks/config.yml b/ansible/roles/ovn-db/tasks/config.yml index 5046bd1041..7bb29c820d 100644 --- a/ansible/roles/ovn-db/tasks/config.yml +++ b/ansible/roles/ovn-db/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ovn_db_services }}" + with_dict: "{{ ovn_db_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -18,9 +15,6 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ ovn_db_services }}" + with_dict: "{{ ovn_db_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/ovs-dpdk/tasks/check-containers.yml b/ansible/roles/ovs-dpdk/tasks/check-containers.yml index 0a38b550fd..4448bd5cbf 100644 --- a/ansible/roles/ovs-dpdk/tasks/check-containers.yml +++ b/ansible/roles/ovs-dpdk/tasks/check-containers.yml @@ -9,9 +9,6 @@ privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ ovsdpdk_services }}" + with_dict: "{{ ovsdpdk_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/ovs-dpdk/tasks/config.yml b/ansible/roles/ovs-dpdk/tasks/config.yml index c6e8421e74..824998a2e8 100644 --- a/ansible/roles/ovs-dpdk/tasks/config.yml +++ b/ansible/roles/ovs-dpdk/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ ovsdpdk_services }}" + with_dict: "{{ ovsdpdk_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services become: true @@ -18,10 +15,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - item.value.enabled | bool - - item.value.host_in_groups | bool - with_dict: "{{ ovsdpdk_services }}" + with_dict: "{{ ovsdpdk_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/placement/tasks/check-containers.yml b/ansible/roles/placement/tasks/check-containers.yml index e8984bf632..c9f56caddf 100644 --- a/ansible/roles/placement/tasks/check-containers.yml +++ b/ansible/roles/placement/tasks/check-containers.yml @@ -13,9 +13,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ placement_services }}" + with_dict: "{{ placement_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/placement/tasks/config.yml b/ansible/roles/placement/tasks/config.yml index 86ad2dc82a..1cd6353b05 100644 --- a/ansible/roles/placement/tasks/config.yml +++ b/ansible/roles/placement/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ placement_services }}" + with_dict: "{{ placement_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ placement_services }}" + with_dict: "{{ placement_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -61,10 +55,7 @@ - "{{ node_custom_config }}/placement/{{ inventory_hostname }}/placement.conf" dest: "{{ node_config_directory }}/{{ item.key }}/placement.conf" mode: "0660" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ placement_services }}" + with_dict: "{{ placement_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -76,9 +67,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/placement-api/placement-api-wsgi.conf" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/placement/{{ inventory_hostname }}/placement-api-wsgi.conf" - "{{ node_custom_config }}/placement/placement-api-wsgi.conf" @@ -94,9 +83,7 @@ src: "migrate-db.rc.j2" dest: "{{ node_config_directory }}/placement-api/migrate-db.rc" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart placement-api container @@ -107,9 +94,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/{{ placement_policy_file }}" mode: "0660" when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - placement_policy_file is defined - with_dict: "{{ placement_services }}" + with_dict: "{{ placement_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/placement/tasks/precheck.yml b/ansible/roles/placement/tasks/precheck.yml index 8131e20809..47cfd750f9 100644 --- a/ansible/roles/placement/tasks/precheck.yml +++ b/ansible/roles/placement/tasks/precheck.yml @@ -16,7 +16,7 @@ - name: Checking free port for Placement API vars: - placement_api: "{{ placement_services['placement-api'] }}" + service: "{{ placement_services['placement-api'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ placement_api_listen_port }}" @@ -25,5 +25,4 @@ state: stopped when: - container_facts['placement_api'] is not defined - - inventory_hostname in groups[placement_api.group] - - placement_api.enabled | bool + - service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/prometheus/tasks/check-containers.yml b/ansible/roles/prometheus/tasks/check-containers.yml index 4673443b9f..373e12847e 100644 --- a/ansible/roles/prometheus/tasks/check-containers.yml +++ b/ansible/roles/prometheus/tasks/check-containers.yml @@ -10,9 +10,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" environment: "{{ item.value.environment | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ prometheus_services }}" + with_dict: "{{ prometheus_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/prometheus/tasks/config.yml b/ansible/roles/prometheus/tasks/config.yml index 9ad3fa9116..52a4d335d8 100644 --- a/ansible/roles/prometheus/tasks/config.yml +++ b/ansible/roles/prometheus/tasks/config.yml @@ -7,10 +7,7 @@ owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ prometheus_services }}" + with_dict: "{{ prometheus_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: copy-certs.yml when: @@ -22,10 +19,7 @@ src: "{{ item.key }}.json.j2" dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ prometheus_services }}" + with_dict: "{{ prometheus_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -48,8 +42,8 @@ dest: "{{ node_config_directory }}/prometheus-server/{{ item.path | basename }}" mode: "0660" when: - - inventory_hostname in groups[service.group] - - service.enabled | bool and enable_prometheus_alertmanager | bool + - service | service_enabled_and_mapped_to_host + - enable_prometheus_alertmanager | bool - prometheus_alert_rules is defined and prometheus_alert_rules.files | length > 0 with_items: "{{ prometheus_alert_rules.files }}" notify: @@ -87,9 +81,7 @@ dest: "{{ node_config_directory }}/prometheus-server/prometheus.yml" mode: "0660" extend_lists: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/prometheus/{{ inventory_hostname }}/prometheus.yml" - "{{ node_custom_config }}/prometheus/prometheus.yml" @@ -105,9 +97,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/prometheus-server/web.yml" mode: "0600" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/prometheus/{{ inventory_hostname }}/web.yml" - "{{ node_custom_config }}/prometheus/web.yml" @@ -123,9 +113,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/prometheus-alertmanager/prometheus-alertmanager.yml" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/prometheus/{{ inventory_hostname }}/prometheus-alertmanager.yml" - "{{ node_custom_config }}/prometheus/prometheus-alertmanager.yml" @@ -152,8 +140,7 @@ dest: "{{ node_config_directory }}/prometheus-alertmanager/{{ item.path | basename }}" mode: 0660 when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + - service | service_enabled_and_mapped_to_host - alertmanager_notification_templates is defined and alertmanager_notification_templates.files | length > 0 with_items: "{{ alertmanager_notification_templates.files }}" notify: @@ -170,9 +157,7 @@ - "{{ role_path }}/templates/my.cnf.j2" dest: "{{ node_config_directory }}/prometheus-mysqld-exporter/my.cnf" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart prometheus-mysqld-exporter container @@ -184,9 +169,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/prometheus-openstack-exporter/clouds.yml" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/prometheus-openstack-exporter/{{ inventory_hostname }}/clouds.yml" - "{{ node_custom_config }}/prometheus-openstack-exporter/clouds.yml" @@ -202,9 +185,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/prometheus-blackbox-exporter/prometheus-blackbox-exporter.yml" mode: "0660" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/prometheus/{{ inventory_hostname }}/prometheus-blackbox-exporter.yml" - "{{ node_custom_config }}/prometheus/prometheus-blackbox-exporter.yml" @@ -252,9 +233,7 @@ vars: base: "{{ node_custom_config }}/prometheus/" service: "{{ prometheus_services['prometheus-server'] }}" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host - name: Copying over prometheus msteams config file vars: @@ -263,9 +242,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/prometheus-msteams/msteams.yml" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/prometheus/{{ inventory_hostname }}/prometheus-msteams.yml" - "{{ node_custom_config }}/prometheus/prometheus-msteams.yml" @@ -280,9 +257,7 @@ src: "{{ item }}" dest: "{{ node_config_directory }}/prometheus-msteams/msteams.tmpl" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/prometheus/{{ inventory_hostname }}/prometheus-msteams.tmpl" - "{{ node_custom_config }}/prometheus/prometheus-msteams.tmpl" diff --git a/ansible/roles/rabbitmq/tasks/check-containers.yml b/ansible/roles/rabbitmq/tasks/check-containers.yml index 740ac66fef..5a6cc9e65f 100644 --- a/ansible/roles/rabbitmq/tasks/check-containers.yml +++ b/ansible/roles/rabbitmq/tasks/check-containers.yml @@ -10,9 +10,6 @@ environment: "{{ item.value.environment }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ rabbitmq_services }}" + with_dict: "{{ rabbitmq_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart rabbitmq container diff --git a/ansible/roles/rabbitmq/tasks/config.yml b/ansible/roles/rabbitmq/tasks/config.yml index b8fed458c6..4f0f0ccf31 100644 --- a/ansible/roles/rabbitmq/tasks/config.yml +++ b/ansible/roles/rabbitmq/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ rabbitmq_services }}" + with_dict: "{{ rabbitmq_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over config.json files for services template: @@ -18,10 +15,7 @@ dest: "{{ node_config_directory }}/{{ project_name }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ rabbitmq_services }}" + with_dict: "{{ rabbitmq_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart rabbitmq container @@ -37,9 +31,7 @@ - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/rabbitmq-env.conf" - "{{ node_custom_config }}/rabbitmq/rabbitmq-env.conf" - "rabbitmq-env.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart rabbitmq container @@ -55,9 +47,7 @@ - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/rabbitmq.conf" - "{{ node_custom_config }}/rabbitmq/rabbitmq.conf" - "rabbitmq.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart rabbitmq container @@ -73,9 +63,7 @@ - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/erl_inetrc" - "{{ node_custom_config }}/rabbitmq/erl_inetrc" - "erl_inetrc.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart rabbitmq container @@ -91,9 +79,7 @@ - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/advanced.config" - "{{ node_custom_config }}/rabbitmq/advanced.config" - "advanced.config.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart rabbitmq container @@ -109,9 +95,7 @@ - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/definitions.json" - "{{ node_custom_config }}/rabbitmq/definitions.json" - "definitions.json.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart rabbitmq container @@ -127,9 +111,7 @@ - "{{ node_custom_config }}/rabbitmq/{{ inventory_hostname }}/enabled_plugins" - "{{ node_custom_config }}/rabbitmq/enabled_plugins" - "enabled_plugins.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart rabbitmq container diff --git a/ansible/roles/redis/tasks/check-containers.yml b/ansible/roles/redis/tasks/check-containers.yml index 9016b7370b..63f7b40bd7 100644 --- a/ansible/roles/redis/tasks/check-containers.yml +++ b/ansible/roles/redis/tasks/check-containers.yml @@ -10,9 +10,6 @@ volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ redis_services }}" + with_dict: "{{ redis_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/redis/tasks/config.yml b/ansible/roles/redis/tasks/config.yml index e6cfc003d6..bf4a1f4b3f 100644 --- a/ansible/roles/redis/tasks/config.yml +++ b/ansible/roles/redis/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ redis_services }}" + with_dict: "{{ redis_services | select_services_enabled_and_mapped_to_host }}" - name: Copying over default config.json files template: @@ -18,10 +15,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ redis_services }}" + with_dict: "{{ redis_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -31,9 +25,6 @@ dest: "{{ node_config_directory }}/{{ item.key }}/redis.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ redis_services }}" + with_dict: "{{ redis_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/redis/tasks/precheck.yml b/ansible/roles/redis/tasks/precheck.yml index e9abc14aa4..73c218be5f 100644 --- a/ansible/roles/redis/tasks/precheck.yml +++ b/ansible/roles/redis/tasks/precheck.yml @@ -16,7 +16,7 @@ - name: Checking free port for Redis vars: - redis: "{{ redis_services['redis'] }}" + service: "{{ redis_services['redis'] }}" wait_for: host: "{{ api_interface_address }}" port: "{{ redis_port }}" @@ -25,5 +25,4 @@ state: stopped when: - container_facts['redis'] is not defined - - inventory_hostname in groups[redis.group] - - redis.enabled | bool + - service | service_enabled_and_mapped_to_host diff --git a/ansible/roles/skyline/tasks/check-containers.yml b/ansible/roles/skyline/tasks/check-containers.yml index 1ece87d607..bc59238e12 100644 --- a/ansible/roles/skyline/tasks/check-containers.yml +++ b/ansible/roles/skyline/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ horizon.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ skyline_services }}" + with_dict: "{{ skyline_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/skyline/tasks/config.yml b/ansible/roles/skyline/tasks/config.yml index c29d16cbb4..75d2b94248 100644 --- a/ansible/roles/skyline/tasks/config.yml +++ b/ansible/roles/skyline/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ skyline_services }}" + with_dict: "{{ skyline_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: copy-certs.yml when: @@ -24,24 +21,19 @@ dest: "{{ node_config_directory }}/{{ item.key }}/skyline.yaml" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ skyline_services }}" + with_dict: "{{ skyline_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" - name: Copying over gunicorn.py files for services vars: - skyline_apiserver: "{{ skyline_services['skyline-apiserver'] }}" + service: "{{ skyline_services['skyline-apiserver'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/skyline-apiserver/gunicorn.py" mode: "0660" become: true - when: - - inventory_hostname in groups['skyline-apiserver'] - - skyline_apiserver.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/skyline/gunicorn.py" - "gunicorn.py.j2" @@ -50,15 +42,13 @@ - name: Copying over nginx.conf files for services vars: - skyline_console: "{{ skyline_services['skyline-console'] }}" + service: "{{ skyline_services['skyline-console'] }}" template: src: "{{ item }}" dest: "{{ node_config_directory }}/skyline-console/nginx.conf" mode: "0660" become: true - when: - - inventory_hostname in groups['skyline-console'] - - skyline_console.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/skyline/nginx.conf" - "nginx.conf.j2" @@ -71,24 +61,20 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ skyline_services }}" + with_dict: "{{ skyline_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" - name: Copying over custom logos become: true vars: - skyline_console: "{{ skyline_services['skyline-console'] }}" + service: "{{ skyline_services['skyline-console'] }}" copy: src: "{{ node_custom_config }}/skyline/logos/{{ item }}" dest: "{{ node_config_directory }}/skyline-console/logos/" mode: 0660 when: - - skyline_console.enabled | bool - - inventory_hostname in groups[skyline_console.group] + - service | service_enabled_and_mapped_to_host - skyline_custom_logos | length > 0 with_items: "{{ skyline_custom_logos }}" notify: diff --git a/ansible/roles/tacker/tasks/check-containers.yml b/ansible/roles/tacker/tasks/check-containers.yml index e6e0099792..fb3ac51407 100644 --- a/ansible/roles/tacker/tasks/check-containers.yml +++ b/ansible/roles/tacker/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - item.value.host_in_groups | bool - - item.value.enabled | bool - with_dict: "{{ tacker_services }}" + with_dict: "{{ tacker_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/tacker/tasks/config.yml b/ansible/roles/tacker/tasks/config.yml index ecdf54db28..518eee31d4 100644 --- a/ansible/roles/tacker/tasks/config.yml +++ b/ansible/roles/tacker/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - item.value.host_in_groups | bool - - item.value.enabled | bool - with_dict: "{{ tacker_services }}" + with_dict: "{{ tacker_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - with_dict: "{{ tacker_services }}" - when: - - item.value.host_in_groups | bool - - item.value.enabled + with_dict: "{{ tacker_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -61,10 +55,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/tacker.conf" mode: "0660" become: true - with_dict: "{{ tacker_services }}" - when: - - item.value.host_in_groups | bool - - item.value.enabled | bool + with_dict: "{{ tacker_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -75,9 +66,7 @@ mode: "0660" become: true when: - - item.value.host_in_groups | bool - - item.value.enabled | bool - tacker_policy_file is defined - with_dict: "{{ tacker_services }}" + with_dict: "{{ tacker_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/telegraf/tasks/check-containers.yml b/ansible/roles/telegraf/tasks/check-containers.yml index 7feb227d6f..da1cfd849b 100644 --- a/ansible/roles/telegraf/tasks/check-containers.yml +++ b/ansible/roles/telegraf/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes }}" pid_mode: "{{ item.value.pid_mode }}" dimensions: "{{ item.value.dimensions }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ telegraf_services }}" + with_dict: "{{ telegraf_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/telegraf/tasks/config.yml b/ansible/roles/telegraf/tasks/config.yml index a0a947f2ee..7f7b6338a0 100644 --- a/ansible/roles/telegraf/tasks/config.yml +++ b/ansible/roles/telegraf/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ telegraf_services }}" + with_dict: "{{ telegraf_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: copy-certs.yml when: @@ -22,10 +19,7 @@ dest: "{{ node_config_directory }}/telegraf/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ telegraf_services }}" + with_dict: "{{ telegraf_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart telegraf container @@ -37,9 +31,7 @@ dest: "{{ node_config_directory }}/telegraf/telegraf.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host with_first_found: - "{{ node_custom_config }}/telegraf/{{ inventory_hostname }}/telegraf.conf" - "{{ node_custom_config }}/telegraf/telegraf.conf" @@ -55,9 +47,7 @@ dest: "{{ node_config_directory }}/telegraf/config" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - item.value.enabled | bool + when: service | service_enabled_and_mapped_to_host with_fileglob: - "{{ role_path }}/templates/config/*.conf" notify: diff --git a/ansible/roles/trove/tasks/check-containers.yml b/ansible/roles/trove/tasks/check-containers.yml index d2a1cb2a62..d5beeba07c 100644 --- a/ansible/roles/trove/tasks/check-containers.yml +++ b/ansible/roles/trove/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ trove_services }}" + with_dict: "{{ trove_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/trove/tasks/config.yml b/ansible/roles/trove/tasks/config.yml index 6b5da98056..9c3d9d5f3f 100644 --- a/ansible/roles/trove/tasks/config.yml +++ b/ansible/roles/trove/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ trove_services }}" + with_dict: "{{ trove_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ trove_services }}" + with_dict: "{{ trove_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -60,9 +54,7 @@ - "{{ node_custom_config }}/trove/{{ inventory_hostname }}/trove-wsgi.conf" - "{{ node_custom_config }}/trove/trove-wsgi.conf" - "trove-wsgi.conf.j2" - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart trove-api container @@ -81,9 +73,7 @@ become: true when: - item.key in services_need_confs - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ trove_services }}" + with_dict: "{{ trove_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -100,10 +90,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/trove.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ trove_services }}" + with_dict: "{{ trove_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -114,7 +101,6 @@ mode: "0660" when: - trove_policy_file is defined - - inventory_hostname in groups[item.value.group] - with_dict: "{{ trove_services }}" + with_dict: "{{ trove_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/venus/tasks/check-containers.yml b/ansible/roles/venus/tasks/check-containers.yml index 63da455671..a44b1b03f8 100644 --- a/ansible/roles/venus/tasks/check-containers.yml +++ b/ansible/roles/venus/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ venus_services }}" + with_dict: "{{ venus_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/venus/tasks/config.yml b/ansible/roles/venus/tasks/config.yml index 37fccd9767..7a2b5f377a 100644 --- a/ansible/roles/venus/tasks/config.yml +++ b/ansible/roles/venus/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ venus_services }}" + with_dict: "{{ venus_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ venus_services }}" + with_dict: "{{ venus_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -61,10 +55,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/venus.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ venus_services }}" + with_dict: "{{ venus_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" @@ -75,7 +66,6 @@ mode: "0660" when: - venus_policy_file is defined - - inventory_hostname in groups[item.value.group] - with_dict: "{{ venus_services }}" + with_dict: "{{ venus_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/watcher/tasks/check-containers.yml b/ansible/roles/watcher/tasks/check-containers.yml index 1af099abb3..a7beab9674 100644 --- a/ansible/roles/watcher/tasks/check-containers.yml +++ b/ansible/roles/watcher/tasks/check-containers.yml @@ -9,9 +9,6 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ watcher_services }}" + with_dict: "{{ watcher_services | select_services_enabled_and_mapped_to_host }}" notify: - "Restart {{ item.key }} container" diff --git a/ansible/roles/watcher/tasks/config.yml b/ansible/roles/watcher/tasks/config.yml index 2b1688a09c..fee20f8173 100644 --- a/ansible/roles/watcher/tasks/config.yml +++ b/ansible/roles/watcher/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ watcher_services }}" + with_dict: "{{ watcher_services | select_services_enabled_and_mapped_to_host }}" - name: Check if policies shall be overwritten stat: @@ -41,10 +38,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ watcher_services }}" + with_dict: "{{ watcher_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -61,10 +55,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/watcher.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ watcher_services }}" + with_dict: "{{ watcher_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -76,8 +67,6 @@ become: true when: - watcher_policy_file is defined - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ watcher_services }}" + with_dict: "{{ watcher_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/ansible/roles/zun/tasks/check-containers.yml b/ansible/roles/zun/tasks/check-containers.yml index 4f7489c908..2f680d12f6 100644 --- a/ansible/roles/zun/tasks/check-containers.yml +++ b/ansible/roles/zun/tasks/check-containers.yml @@ -10,10 +10,7 @@ volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ zun_services }}" + with_dict: "{{ zun_services | select_services_enabled_and_mapped_to_host }}" notify: # NOTE(yoctozepto): Zun differs from other projects because we want # to differentiate between config change and container property diff --git a/ansible/roles/zun/tasks/config.yml b/ansible/roles/zun/tasks/config.yml index 5b10fb0677..f94e6b72a2 100644 --- a/ansible/roles/zun/tasks/config.yml +++ b/ansible/roles/zun/tasks/config.yml @@ -7,10 +7,7 @@ group: "{{ config_owner_group }}" mode: "0770" become: true - when: - - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool - with_dict: "{{ zun_services }}" + with_dict: "{{ zun_services | select_services_enabled_and_mapped_to_host }}" - include_tasks: external_ceph.yml when: @@ -46,10 +43,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/config.json" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ zun_services }}" + with_dict: "{{ zun_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -66,10 +60,7 @@ dest: "{{ node_config_directory }}/{{ item.key }}/zun.conf" mode: "0660" become: true - when: - - item.value.enabled | bool - - inventory_hostname in groups[item.value.group] - with_dict: "{{ zun_services }}" + with_dict: "{{ zun_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container @@ -81,9 +72,7 @@ dest: "{{ node_config_directory }}/zun-api/wsgi-zun.conf" mode: "0660" become: true - when: - - inventory_hostname in groups[service.group] - - service.enabled | bool + when: service | service_enabled_and_mapped_to_host notify: - Restart zun-api container @@ -95,7 +84,6 @@ become: true when: - zun_policy_file is defined - - inventory_hostname in groups[item.value.group] - with_dict: "{{ zun_services }}" + with_dict: "{{ zun_services | select_services_enabled_and_mapped_to_host }}" notify: - Restart {{ item.key }} container diff --git a/releasenotes/notes/performance-improvements-42c34ebf4243312a.yaml b/releasenotes/notes/performance-improvements-42c34ebf4243312a.yaml new file mode 100644 index 0000000000..deafb0a477 --- /dev/null +++ b/releasenotes/notes/performance-improvements-42c34ebf4243312a.yaml @@ -0,0 +1,13 @@ +--- +features: + - | + Implement jinja filters for service dicts. + Using select_services_enabled_and_mapped_to_host + filter gets rid of some overhead caused by + ansible skipping items in tasks. + With bigger amount of hosts, this overhead + is non-insignificant. + Usage of service_enabled_and_mapped_to_host + filter is mostly cosmetic and has no effect + on the performance. + `Blueprint performance-improvements `__