From 1009931162aced2daa78ec9943bbad2530360f8d Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Tue, 19 Nov 2019 09:34:23 +0000 Subject: [PATCH] Change local_action to delegate_to: localhost As part of the effort to implement Ansible code linting in CI (using ansible-lint) - we need to implement recommendations from ansible-lint output [1]. One of them is to stop using local_action in favor of delegate_to - to increase readability and and match the style of typical ansible tasks. [1]: https://review.opendev.org/694779/ Partially implements: blueprint ansible-lint Change-Id: I46c259ddad5a6aaf9c7301e6c44cd8a1d5c457d3 --- ansible/roles/aodh/tasks/config.yml | 4 +- ansible/roles/barbican/tasks/config.yml | 8 ++- ansible/roles/blazar/tasks/config.yml | 4 +- ansible/roles/ceilometer/tasks/config.yml | 33 ++++++++--- ansible/roles/ceilometer/tasks/precheck.yml | 3 +- ansible/roles/ceph/tasks/bootstrap_mons.yml | 22 +++++-- ansible/roles/ceph/tasks/precheck.yml | 3 +- ansible/roles/cinder/tasks/config.yml | 4 +- ansible/roles/cinder/tasks/precheck.yml | 3 +- ansible/roles/cloudkitty/tasks/config.yml | 8 ++- ansible/roles/congress/tasks/config.yml | 4 +- ansible/roles/cyborg/tasks/config.yml | 8 ++- ansible/roles/designate/tasks/config.yml | 4 +- ansible/roles/freezer/tasks/config.yml | 4 +- ansible/roles/glance/tasks/config.yml | 4 +- ansible/roles/gnocchi/tasks/config.yml | 4 +- ansible/roles/grafana/tasks/config.yml | 8 ++- ansible/roles/haproxy/tasks/precheck.yml | 58 +++++++++++++++---- ansible/roles/heat/tasks/config.yml | 4 +- ansible/roles/horizon/tasks/policy_item.yml | 4 +- ansible/roles/ironic/tasks/config.yml | 4 +- ansible/roles/ironic/tasks/precheck.yml | 4 +- ansible/roles/keystone/tasks/config.yml | 18 ++++-- ansible/roles/keystone/tasks/precheck.yml | 4 +- ansible/roles/kuryr/tasks/config.yml | 4 +- ansible/roles/magnum/tasks/config.yml | 4 +- ansible/roles/manila/tasks/config.yml | 4 +- .../roles/mariadb/tasks/lookup_cluster.yml | 23 ++++++-- .../roles/mariadb/tasks/recover_cluster.yml | 10 +++- ansible/roles/masakari/tasks/config.yml | 4 +- ansible/roles/mistral/tasks/config.yml | 4 +- ansible/roles/monasca/tasks/config.yml | 12 ++-- .../roles/mongodb/tasks/bootstrap_cluster.yml | 10 +++- ansible/roles/murano/tasks/config.yml | 4 +- ansible/roles/neutron/tasks/config.yml | 8 ++- ansible/roles/neutron/tasks/precheck.yml | 9 ++- ansible/roles/nova-cell/tasks/config.yml | 4 +- .../roles/nova-cell/tasks/external_ceph.yml | 8 ++- ansible/roles/nova/tasks/config.yml | 4 +- ansible/roles/octavia/tasks/config.yml | 4 +- ansible/roles/octavia/tasks/precheck.yml | 4 +- ansible/roles/panko/tasks/config.yml | 4 +- ansible/roles/placement/tasks/config.yml | 4 +- .../roles/prechecks/tasks/package_checks.yml | 3 +- .../roles/prechecks/tasks/service_checks.yml | 7 ++- ansible/roles/prometheus/tasks/config.yml | 4 +- ansible/roles/qinling/tasks/config.yml | 4 +- ansible/roles/rally/tasks/config.yml | 4 +- ansible/roles/sahara/tasks/config.yml | 4 +- ansible/roles/searchlight/tasks/config.yml | 4 +- ansible/roles/senlin/tasks/config.yml | 4 +- ansible/roles/swift/tasks/config.yml | 4 +- ansible/roles/swift/tasks/precheck.yml | 7 ++- ansible/roles/tacker/tasks/config.yml | 4 +- ansible/roles/trove/tasks/config.yml | 4 +- ansible/roles/vitrage/tasks/config.yml | 4 +- ansible/roles/vitrage/tasks/precheck.yml | 4 +- ansible/roles/watcher/tasks/config.yml | 4 +- ansible/roles/zun/tasks/config.yml | 4 +- ansible/roles/zun/tasks/precheck.yml | 3 +- tools/validate-all-file.py | 20 ++++--- 61 files changed, 332 insertions(+), 112 deletions(-) diff --git a/ansible/roles/aodh/tasks/config.yml b/ansible/roles/aodh/tasks/config.yml index a9cf266753..dbcdace495 100644 --- a/ansible/roles/aodh/tasks/config.yml +++ b/ansible/roles/aodh/tasks/config.yml @@ -13,8 +13,10 @@ with_dict: "{{ aodh_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: aodh_policy with_first_found: - files: "{{ supported_policy_format_list }}" diff --git a/ansible/roles/barbican/tasks/config.yml b/ansible/roles/barbican/tasks/config.yml index c8a8c70623..7ea8170976 100644 --- a/ansible/roles/barbican/tasks/config.yml +++ b/ansible/roles/barbican/tasks/config.yml @@ -29,8 +29,10 @@ - "barbican-api/vassals" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: barbican_policy with_first_found: - files: "{{ supported_policy_format_list }}" @@ -78,8 +80,10 @@ - name: Checking whether barbican-api-paste.ini file exists vars: service: "{{ barbican_services['barbican-api'] }}" - local_action: stat path="{{ node_custom_config }}/barbican/barbican-api-paste.ini" + stat: + path: "{{ node_custom_config }}/barbican/barbican-api-paste.ini" run_once: True + delegate_to: localhost register: check_barbican_api_paste_ini when: - inventory_hostname in groups[service.group] diff --git a/ansible/roles/blazar/tasks/config.yml b/ansible/roles/blazar/tasks/config.yml index adf0562554..7ac5462a73 100644 --- a/ansible/roles/blazar/tasks/config.yml +++ b/ansible/roles/blazar/tasks/config.yml @@ -13,8 +13,10 @@ with_dict: "{{ blazar_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: blazar_policy with_first_found: - files: "{{ supported_policy_format_list }}" diff --git a/ansible/roles/ceilometer/tasks/config.yml b/ansible/roles/ceilometer/tasks/config.yml index 0eeb597b18..1e3ba49a86 100644 --- a/ansible/roles/ceilometer/tasks/config.yml +++ b/ansible/roles/ceilometer/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ ceilometer_services }}" - name: Check if the folder for custom meter definitions exist - local_action: stat path="{{ node_custom_config }}/ceilometer/{{ ceilometer_custom_meters_local_folder }}" + stat: + path: "{{ node_custom_config }}/ceilometer/{{ ceilometer_custom_meters_local_folder }}" + delegate_to: localhost register: ceilometer_custom_meters_folder - name: Set variable that indicates if we have a folder for custom meter YAML files @@ -21,7 +23,10 @@ custom_meter_folder_exist: "{{ ceilometer_custom_meters_folder.stat.exists and ceilometer_custom_meters_folder.stat.isdir }}" - name: Find all *.yaml files in custom meter definitions folder (if the folder exist) - local_action: find paths="{{ node_custom_config }}/ceilometer/{{ ceilometer_custom_meters_local_folder }}" patterns="*.yaml" + find: + paths: "{{ node_custom_config }}/ceilometer/{{ ceilometer_custom_meters_local_folder }}" + patterns: "*.yaml" + delegate_to: localhost register: ceilometer_custom_meters_folder_found_files when: custom_meter_folder_exist @@ -59,7 +64,9 @@ - "Restart {{ item.key }} container" - name: Check if custom polling.yaml exists - local_action: stat path="{{ node_custom_config }}/ceilometer/polling.yaml" + stat: + path: "{{ node_custom_config }}/ceilometer/polling.yaml" + delegate_to: localhost register: ceilometer_polling_file - name: Copying over polling.yaml @@ -84,7 +91,9 @@ - ceilometer_polling_file.stat.exists - name: Check custom gnocchi_resources.yaml exists - local_action: stat path="{{ node_custom_config }}/ceilometer/gnocchi_resources.yaml" + stat: + path: "{{ node_custom_config }}/ceilometer/gnocchi_resources.yaml" + delegate_to: localhost register: ceilometer_gnocchi_resources_file - name: Copying over gnocchi_resources.yaml @@ -109,7 +118,9 @@ - ceilometer_gnocchi_resources_file.stat.exists - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: ceilometer_policy with_first_found: @@ -159,7 +170,9 @@ - "Restart {{ item.key }} container" - name: Check custom event_definitions.yaml exists - local_action: stat path="{{ node_custom_config }}/ceilometer/event_definitions.yaml" + stat: + path: "{{ node_custom_config }}/ceilometer/event_definitions.yaml" + delegate_to: localhost register: ceilometer_event_definitions_file - name: Copying over event_definitions.yaml @@ -196,7 +209,9 @@ - Restart ceilometer-notification container - name: Check custom event_pipeline.yaml exists - local_action: stat path="{{ node_custom_config }}/ceilometer/event_pipeline.yaml" + stat: + path: "{{ node_custom_config }}/ceilometer/event_pipeline.yaml" + delegate_to: localhost register: ceilometer_event_pipeline_file - name: Copying over event_pipeline.yaml @@ -232,7 +247,9 @@ - Restart ceilometer-notification container - name: Check custom pipeline.yaml exists - local_action: stat path="{{ node_custom_config }}/ceilometer/pipeline.yaml" + stat: + path: "{{ node_custom_config }}/ceilometer/pipeline.yaml" + delegate_to: localhost register: ceilometer_pipeline_file - name: Copying over pipeline.yaml diff --git a/ansible/roles/ceilometer/tasks/precheck.yml b/ansible/roles/ceilometer/tasks/precheck.yml index ce5dff8b42..8e6291ddc0 100644 --- a/ansible/roles/ceilometer/tasks/precheck.yml +++ b/ansible/roles/ceilometer/tasks/precheck.yml @@ -1,7 +1,8 @@ --- - name: Checking gnocchi backend for ceilometer + fail: + msg: "gnocchi is required but not enabled" run_once: True - local_action: fail msg="gnocchi is required but not enabled" changed_when: false when: - enable_ceilometer | bool diff --git a/ansible/roles/ceph/tasks/bootstrap_mons.yml b/ansible/roles/ceph/tasks/bootstrap_mons.yml index 1baf6b3fce..f117f60730 100644 --- a/ansible/roles/ceph/tasks/bootstrap_mons.yml +++ b/ansible/roles/ceph/tasks/bootstrap_mons.yml @@ -1,12 +1,19 @@ --- - name: Cleaning up temp file on localhost - local_action: file path=/tmp/kolla_ceph_cluster state=absent + file: + path: /tmp/kolla_ceph_cluster + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: True - name: Creating temp file on localhost - local_action: copy content=None dest=/tmp/kolla_ceph_cluster mode=0644 + copy: + content: None + dest: /tmp/kolla_ceph_cluster + mode: 0644 + delegate_to: localhost changed_when: False check_mode: no run_once: True @@ -20,7 +27,11 @@ register: ceph_mon_config_volume - name: Writing hostname of host with existing cluster files to temp file - local_action: copy content="{{ inventory_hostname }}" dest=/tmp/kolla_ceph_cluster mode=0644 + copy: + content: "{{ inventory_hostname }}" + dest: /tmp/kolla_ceph_cluster + mode: 0644 + delegate_to: localhost changed_when: False check_mode: no when: not ceph_mon_config_volume.changed @@ -30,7 +41,10 @@ delegate_host: "{{ lookup('file', '/tmp/kolla_ceph_cluster') }}" - name: Cleaning up temp file on localhost - local_action: file path=/tmp/kolla_ceph_cluster state=absent + file: + path: /tmp/kolla_ceph_cluster + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: True diff --git a/ansible/roles/ceph/tasks/precheck.yml b/ansible/roles/ceph/tasks/precheck.yml index cda620d697..957b0a98bb 100644 --- a/ansible/roles/ceph/tasks/precheck.yml +++ b/ansible/roles/ceph/tasks/precheck.yml @@ -18,6 +18,7 @@ - inventory_hostname in groups['ceph-rgw'] - name: Check whether the Swift service is enabled - local_action: fail msg='Ceph-rgw conflicts with Swift, and so you should only enable one of them' + fail: + msg: 'Ceph-rgw conflicts with Swift, and so you should only enable one of them' when: enable_swift | bool and enable_ceph_rgw | bool run_once: True diff --git a/ansible/roles/cinder/tasks/config.yml b/ansible/roles/cinder/tasks/config.yml index 1883abae5e..e64bb210e2 100644 --- a/ansible/roles/cinder/tasks/config.yml +++ b/ansible/roles/cinder/tasks/config.yml @@ -28,7 +28,9 @@ inventory_hostname in groups['cinder-backup'] - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: cinder_policy with_first_found: diff --git a/ansible/roles/cinder/tasks/precheck.yml b/ansible/roles/cinder/tasks/precheck.yml index 4756b7d2f1..177c4aed42 100644 --- a/ansible/roles/cinder/tasks/precheck.yml +++ b/ansible/roles/cinder/tasks/precheck.yml @@ -19,7 +19,8 @@ - name: Checking at least one valid backend is enabled for Cinder run_once: True - local_action: fail msg="Please enable at least one backend when enabling Cinder" + fail: + msg: "Please enable at least one backend when enabling Cinder" when: - not skip_cinder_backend_check | bool - not enable_cinder_backend_hnas_nfs | bool diff --git a/ansible/roles/cloudkitty/tasks/config.yml b/ansible/roles/cloudkitty/tasks/config.yml index 7ab261265f..700803ccd3 100644 --- a/ansible/roles/cloudkitty/tasks/config.yml +++ b/ansible/roles/cloudkitty/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ cloudkitty_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: cloudkitty_policy with_first_found: @@ -30,7 +32,9 @@ - cloudkitty_policy.results - name: Check if custom {{ cloudkitty_custom_metrics_yaml_file }} exists - local_action: stat path="{{ node_custom_config }}/cloudkitty/{{ cloudkitty_custom_metrics_yaml_file }}" + stat: + path: "{{ node_custom_config }}/cloudkitty/{{ cloudkitty_custom_metrics_yaml_file }}" + delegate_to: localhost register: cloudkitty_custom_metrics_file - name: Copying {{ cloudkitty_custom_metrics_yaml_file }} if it exists diff --git a/ansible/roles/congress/tasks/config.yml b/ansible/roles/congress/tasks/config.yml index 1d69672d21..9f066c4edd 100644 --- a/ansible/roles/congress/tasks/config.yml +++ b/ansible/roles/congress/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ congress_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: congress_policy with_first_found: diff --git a/ansible/roles/cyborg/tasks/config.yml b/ansible/roles/cyborg/tasks/config.yml index 63521b9300..b6adeab877 100644 --- a/ansible/roles/cyborg/tasks/config.yml +++ b/ansible/roles/cyborg/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ cyborg_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: cyborg_policy with_first_found: @@ -79,7 +81,9 @@ - name: Checking whether cyborg-api-paste.ini file exists vars: service: "{{ cyborg_services['cyborg-api'] }}" - local_action: stat path="{{ node_custom_config }}/cyborg/cyborg-api-paste.ini" + stat: + path: "{{ node_custom_config }}/cyborg/cyborg-api-paste.ini" + delegate_to: localhost run_once: True register: check_cyborg_api_paste_ini when: diff --git a/ansible/roles/designate/tasks/config.yml b/ansible/roles/designate/tasks/config.yml index 1f5e5e49de..bf8f8d441b 100644 --- a/ansible/roles/designate/tasks/config.yml +++ b/ansible/roles/designate/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ designate_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: designate_policy with_first_found: diff --git a/ansible/roles/freezer/tasks/config.yml b/ansible/roles/freezer/tasks/config.yml index c2ea2cb6d3..648882e934 100644 --- a/ansible/roles/freezer/tasks/config.yml +++ b/ansible/roles/freezer/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ freezer_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: freezer_policy with_first_found: diff --git a/ansible/roles/glance/tasks/config.yml b/ansible/roles/glance/tasks/config.yml index a00dfa460b..8fe21562b8 100644 --- a/ansible/roles/glance/tasks/config.yml +++ b/ansible/roles/glance/tasks/config.yml @@ -23,7 +23,9 @@ - glance_backend_ceph | bool - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: glance_policy with_first_found: diff --git a/ansible/roles/gnocchi/tasks/config.yml b/ansible/roles/gnocchi/tasks/config.yml index e93caa2e7c..0f6bdacb63 100644 --- a/ansible/roles/gnocchi/tasks/config.yml +++ b/ansible/roles/gnocchi/tasks/config.yml @@ -23,7 +23,9 @@ - gnocchi_backend_storage == 'ceph' - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: gnocchi_policy with_first_found: diff --git a/ansible/roles/grafana/tasks/config.yml b/ansible/roles/grafana/tasks/config.yml index 0c695c5ed6..174f011f01 100644 --- a/ansible/roles/grafana/tasks/config.yml +++ b/ansible/roles/grafana/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ grafana_services }}" - name: Check if extra configuration file exists - local_action: find path="{{ node_custom_config }}/grafana/" + find: + path: "{{ node_custom_config }}/grafana/" + delegate_to: localhost changed_when: False run_once: True register: check_extra_conf_grafana @@ -63,7 +65,9 @@ - Restart grafana container - name: Check if custom grafana home dashboard exists - local_action: "stat path={{ node_custom_config }}/grafana/grafana_home_dashboard.json" + stat: + path: "{{ node_custom_config }}/grafana/grafana_home_dashboard.json" + delegate_to: localhost register: grafana_custom_dashboard_file run_once: True diff --git a/ansible/roles/haproxy/tasks/precheck.yml b/ansible/roles/haproxy/tasks/precheck.yml index 7dd8db2651..18a88d6260 100644 --- a/ansible/roles/haproxy/tasks/precheck.yml +++ b/ansible/roles/haproxy/tasks/precheck.yml @@ -8,7 +8,10 @@ register: container_facts - name: Clearing temp kolla_keepalived_running file - local_action: file path=/tmp/kolla_keepalived_running state=absent + file: + path: /tmp/kolla_keepalived_running + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: true @@ -16,15 +19,23 @@ - enable_keepalived | bool - name: Create empty temp kolla_keepalived_running file - local_action: copy content=None dest=/tmp/kolla_keepalived_running mode=0644 + copy: + content: None + dest: /tmp/kolla_keepalived_running + mode: 0644 changed_when: False + delegate_to: localhost check_mode: no run_once: true when: - enable_keepalived | bool - name: Getting hosts who is running keepalived - local_action: copy content={{ ansible_hostname }} dest=/tmp/kolla_keepalived_running mode=0644 + copy: + content: "{{ ansible_hostname }}" + dest: /tmp/kolla_keepalived_running + mode: 0644 + delegate_to: localhost changed_when: False check_mode: no when: @@ -39,7 +50,10 @@ - enable_keepalived | bool - name: Clearing temp kolla_keepalived_running file - local_action: file path=/tmp/kolla_keepalived_running state=absent + file: + path: /tmp/kolla_keepalived_running + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: true @@ -47,19 +61,30 @@ - enable_keepalived | bool - name: Clearing temp kolla_haproxy_running file - local_action: file path=/tmp/kolla_haproxy_running state=absent + file: + path: /tmp/kolla_haproxy_running + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: true - name: Create empty temp kolla_haproxy_running file - local_action: copy content=None dest=/tmp/kolla_haproxy_running mode=0644 + copy: + content: None + dest: /tmp/kolla_haproxy_running + mode: 0644 + delegate_to: localhost changed_when: False check_mode: no run_once: true - name: Getting hosts who is running haproxy - local_action: copy content={{ ansible_hostname }} dest=/tmp/kolla_haproxy_running mode=0644 + copy: + content: "{{ ansible_hostname }}" + dest: /tmp/kolla_haproxy_running + mode: 0644 + delegate_to: localhost changed_when: False check_mode: no when: @@ -72,35 +97,44 @@ host_running_haproxy: "{{ lookup('file', '/tmp/kolla_haproxy_running') }}" - name: Clearing temp kolla_haproxy_running file - local_action: file path=/tmp/kolla_haproxy_running state=absent + file: + path: /tmp/kolla_haproxy_running + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: true - name: Checking if external haproxy certificate exists run_once: true - local_action: stat path={{ kolla_external_fqdn_cert }} + stat: + path: "{{ kolla_external_fqdn_cert }}" + delegate_to: localhost register: haproxy_cert_file changed_when: false when: kolla_enable_tls_external | bool - name: Fail if external haproxy certificate is absent run_once: true - local_action: fail msg="External haproxy certificate file is not found. It is configured via 'kolla_external_fqdn_cert'" + fail: + msg: "External haproxy certificate file is not found. It is configured via 'kolla_external_fqdn_cert'" when: - kolla_enable_tls_external | bool - haproxy_cert_file.stat.exists == false - name: Checking if internal haproxy certificate exists run_once: true - local_action: stat path={{ kolla_internal_fqdn_cert }} + stat: + path: "{{ kolla_internal_fqdn_cert }}" + delegate_to: localhost register: haproxy_internal_cert_file changed_when: false when: kolla_enable_tls_internal | bool - name: Fail if internal haproxy certificate is absent run_once: true - local_action: fail msg="Internal haproxy certificate file is not found. It is configured via 'kolla_internal_fqdn_cert'" + fail: + msg: "Internal haproxy certificate file is not found. It is configured via 'kolla_internal_fqdn_cert'" when: - kolla_enable_tls_internal | bool - haproxy_internal_cert_file.stat.exists == false diff --git a/ansible/roles/heat/tasks/config.yml b/ansible/roles/heat/tasks/config.yml index 3d55e6bb1c..1cb4638397 100644 --- a/ansible/roles/heat/tasks/config.yml +++ b/ansible/roles/heat/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ heat_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: heat_policy with_first_found: diff --git a/ansible/roles/horizon/tasks/policy_item.yml b/ansible/roles/horizon/tasks/policy_item.yml index d8a777d207..4df630b398 100644 --- a/ansible/roles/horizon/tasks/policy_item.yml +++ b/ansible/roles/horizon/tasks/policy_item.yml @@ -5,7 +5,9 @@ supported_policy_files: "{{ supported_policy_format_list | map('regex_replace', '(.+)', '{{ project_name }}_\\1') | list }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ fullpath }}" + stat: + path: "{{ fullpath }}" + delegate_to: localhost run_once: True register: overwritten_files with_first_found: diff --git a/ansible/roles/ironic/tasks/config.yml b/ansible/roles/ironic/tasks/config.yml index 48243abd45..eea6b194c8 100644 --- a/ansible/roles/ironic/tasks/config.yml +++ b/ansible/roles/ironic/tasks/config.yml @@ -20,7 +20,9 @@ with_dict: "{{ ironic_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: ironic_policy with_first_found: diff --git a/ansible/roles/ironic/tasks/precheck.yml b/ansible/roles/ironic/tasks/precheck.yml index fe5eca9c6d..ba8d782997 100644 --- a/ansible/roles/ironic/tasks/precheck.yml +++ b/ansible/roles/ironic/tasks/precheck.yml @@ -43,7 +43,9 @@ - inventory_hostname in groups['ironic-ipxe'] - name: Checking ironic-agent files exist for Ironic Inspector - local_action: stat path="{{ node_custom_config }}/ironic/{{ item }}" + stat: + path: "{{ node_custom_config }}/ironic/{{ item }}" + delegate_to: localhost run_once: True register: result failed_when: not result.stat.exists diff --git a/ansible/roles/keystone/tasks/config.yml b/ansible/roles/keystone/tasks/config.yml index 08f0de6860..75d9b98196 100644 --- a/ansible/roles/keystone/tasks/config.yml +++ b/ansible/roles/keystone/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ keystone_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: keystone_policy with_first_found: @@ -30,7 +32,9 @@ - keystone_policy.results - name: Check if Keystone domain-specific config is supplied - local_action: stat path="{{ node_custom_config }}/keystone/domains" + stat: + path: "{{ node_custom_config }}/keystone/domains" + delegate_to: localhost run_once: True register: keystone_domain_directory @@ -82,7 +86,11 @@ - keystone_domain_directory.stat.exists - name: Get file list in custom domains folder - local_action: find path="{{ node_custom_config }}/keystone/domains" recurse=no file_type=file + find: + path: "{{ node_custom_config }}/keystone/domains" + recurse: no + file_type: file + delegate_to: localhost register: keystone_domains when: keystone_domain_directory.stat.exists @@ -139,7 +147,9 @@ - name: Checking whether keystone-paste.ini file exists vars: keystone: "{{ keystone_services.keystone }}" - local_action: stat path="{{ node_custom_config }}/keystone/keystone-paste.ini" + stat: + path: "{{ node_custom_config }}/keystone/keystone-paste.ini" + delegate_to: localhost run_once: True register: check_keystone_paste_ini when: diff --git a/ansible/roles/keystone/tasks/precheck.yml b/ansible/roles/keystone/tasks/precheck.yml index f48d8c6f4b..fc7d8cd0ca 100644 --- a/ansible/roles/keystone/tasks/precheck.yml +++ b/ansible/roles/keystone/tasks/precheck.yml @@ -45,7 +45,9 @@ - name: Checking fernet_token_expiry in globals.yml. Update fernet_token_expiry to allowed value if this task fails run_once: true - local_action: command awk '/^fernet_token_expiry/ { print $2 }' "{{ node_config }}/globals.yml" + command: + cmd: awk '/^fernet_token_expiry/ { print $2 }' "{{ node_config }}/globals.yml" + delegate_to: localhost register: result changed_when: false failed_when: result.stdout | regex_replace('(60|120|180|240|300|360|600|720|900|1200|1800|3600|7200|10800|14400|21600|28800|43200|86400|604800)', '') is search(".+") diff --git a/ansible/roles/kuryr/tasks/config.yml b/ansible/roles/kuryr/tasks/config.yml index 11ca493cd2..8b16174c3b 100644 --- a/ansible/roles/kuryr/tasks/config.yml +++ b/ansible/roles/kuryr/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ kuryr_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: kuryr_policy with_first_found: diff --git a/ansible/roles/magnum/tasks/config.yml b/ansible/roles/magnum/tasks/config.yml index 95b91ab2c1..5d4dea08d4 100644 --- a/ansible/roles/magnum/tasks/config.yml +++ b/ansible/roles/magnum/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ magnum_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: magnum_policy with_first_found: diff --git a/ansible/roles/manila/tasks/config.yml b/ansible/roles/manila/tasks/config.yml index c1505dd9a9..5c180e96b9 100644 --- a/ansible/roles/manila/tasks/config.yml +++ b/ansible/roles/manila/tasks/config.yml @@ -27,7 +27,9 @@ - inventory_hostname in groups['manila-share'] - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: manila_policy with_first_found: diff --git a/ansible/roles/mariadb/tasks/lookup_cluster.yml b/ansible/roles/mariadb/tasks/lookup_cluster.yml index 719af9f681..4f7bedf722 100644 --- a/ansible/roles/mariadb/tasks/lookup_cluster.yml +++ b/ansible/roles/mariadb/tasks/lookup_cluster.yml @@ -1,12 +1,20 @@ --- - name: Cleaning up temp file on localhost - local_action: file path=/tmp/kolla_mariadb_cluster state=absent + file: + path: /tmp/kolla_mariadb_cluster + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: True +# NOTE(mnasiadka): Due to the way that we are setting fact has_cluster - content needs to be '' - name: Creating temp file on localhost - local_action: copy content='' dest=/tmp/kolla_mariadb_cluster mode=0644 + copy: + content: '' + dest: /tmp/kolla_mariadb_cluster + mode: 0644 + delegate_to: localhost changed_when: False check_mode: no run_once: True @@ -20,7 +28,11 @@ register: mariadb_volume - name: Writing hostname of host with existing cluster files to temp file - local_action: copy content={{ ansible_hostname }} dest=/tmp/kolla_mariadb_cluster mode=0644 + copy: + content: "{{ ansible_hostname }}" + dest: /tmp/kolla_mariadb_cluster + mode: 0644 + delegate_to: localhost changed_when: False check_mode: no when: mariadb_volume is not changed @@ -30,7 +42,10 @@ has_cluster: "{{ lookup('file', '/tmp/kolla_mariadb_cluster') | length > 0 }}" - name: Cleaning up temp file on localhost - local_action: file path=/tmp/kolla_mariadb_cluster state=absent + file: + path: /tmp/kolla_mariadb_cluster + state: absent + delegate_to: localhost changed_when: False check_mode: no run_once: True diff --git a/ansible/roles/mariadb/tasks/recover_cluster.yml b/ansible/roles/mariadb/tasks/recover_cluster.yml index 0887281f13..4c097d80f8 100644 --- a/ansible/roles/mariadb/tasks/recover_cluster.yml +++ b/ansible/roles/mariadb/tasks/recover_cluster.yml @@ -11,10 +11,10 @@ check_mode: no - name: Cleaning up temp file on localhost - local_action: - module: file + file: path: /tmp/kolla_mariadb_recover_inventory_name state: absent + delegate_to: localhost changed_when: false check_mode: no run_once: true @@ -81,7 +81,11 @@ changed_when: false - name: Writing hostname of host with the largest seqno to temp file - local_action: copy content={{ inventory_hostname }} dest=/tmp/kolla_mariadb_recover_inventory_name mode=0644 + copy: + content: "{{ inventory_hostname }}" + dest: /tmp/kolla_mariadb_recover_inventory_name + mode: 0644 + delegate_to: localhost changed_when: false when: seqno_compare.results | map(attribute='stdout') | join('') == "" diff --git a/ansible/roles/masakari/tasks/config.yml b/ansible/roles/masakari/tasks/config.yml index 3028aeb258..f81109d346 100644 --- a/ansible/roles/masakari/tasks/config.yml +++ b/ansible/roles/masakari/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ masakari_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: masakari_policy with_first_found: diff --git a/ansible/roles/mistral/tasks/config.yml b/ansible/roles/mistral/tasks/config.yml index 584ceae70c..47e337954f 100644 --- a/ansible/roles/mistral/tasks/config.yml +++ b/ansible/roles/mistral/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ mistral_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: mistral_policy with_first_found: diff --git a/ansible/roles/monasca/tasks/config.yml b/ansible/roles/monasca/tasks/config.yml index f4bd91caeb..9b8b56ae53 100644 --- a/ansible/roles/monasca/tasks/config.yml +++ b/ansible/roles/monasca/tasks/config.yml @@ -59,13 +59,13 @@ - service.enabled | bool - name: Find monasca-agent-collector plugin configuration files - local_action: - module: find + find: paths: - "{{ role_path }}/templates/monasca-agent-collector/plugins/" - "{{ node_custom_config }}/monasca/agent_plugins/" - "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/agent_plugins/" patterns: '*.yaml' + delegate_to: localhost register: agent_plugins - name: Copying over monasca-agent-collector plugins @@ -221,10 +221,10 @@ - service.enabled | bool - name: Find custom logstash patterns - local_action: - module: find + find: path: "{{ node_custom_config }}/monasca/logstash_patterns" pattern: "*" + delegate_to: localhost run_once: True register: monasca_custom_logstash_patterns @@ -356,7 +356,9 @@ - Restart monasca-notification container - name: Check for monasca-notification templates - local_action: stat path="{{ node_custom_config }}/monasca/notification_templates" + stat: + path: "{{ node_custom_config }}/monasca/notification_templates" + delegate_to: localhost run_once: True register: notification_templates diff --git a/ansible/roles/mongodb/tasks/bootstrap_cluster.yml b/ansible/roles/mongodb/tasks/bootstrap_cluster.yml index c8633d4a25..46f3164484 100644 --- a/ansible/roles/mongodb/tasks/bootstrap_cluster.yml +++ b/ansible/roles/mongodb/tasks/bootstrap_cluster.yml @@ -1,6 +1,9 @@ --- - name: Copying the mongodb replication set bootstrap script - local_action: template src=bootstrap_cluster.js.j2 dest=/tmp/mongodb_bootstrap_replication_set.js + template: + src: bootstrap_cluster.js.j2 + dest: /tmp/mongodb_bootstrap_replication_set.js + delegate_to: localhost run_once: True - name: Bootstrapping the mongodb replication set @@ -12,7 +15,10 @@ run_once: True - name: Deleting the mongodb replication set bootstrap script - local_action: file path=/tmp/mongodb_bootstrap_replication_set.js state=absent + file: + path: /tmp/mongodb_bootstrap_replication_set.js + state: absent + delegate_to: localhost changed_when: false failed_when: false run_once: True diff --git a/ansible/roles/murano/tasks/config.yml b/ansible/roles/murano/tasks/config.yml index 89eb1c22dd..e6be02ca71 100644 --- a/ansible/roles/murano/tasks/config.yml +++ b/ansible/roles/murano/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ murano_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: murano_policy with_first_found: diff --git a/ansible/roles/neutron/tasks/config.yml b/ansible/roles/neutron/tasks/config.yml index f967f8bdac..08837414bf 100644 --- a/ansible/roles/neutron/tasks/config.yml +++ b/ansible/roles/neutron/tasks/config.yml @@ -26,7 +26,9 @@ with_dict: "{{ neutron_services }}" - name: Check if extra ml2 plugins exists - local_action: find path="{{ node_custom_config }}/neutron/plugins/" + find: + path: "{{ node_custom_config }}/neutron/plugins/" + delegate_to: localhost run_once: True changed_when: False register: check_extra_ml2_plugins @@ -313,7 +315,9 @@ - "Restart {{ service_name }} container" - name: Check if policies shall be overwritten - local_action: stat path="{{ node_custom_config }}/neutron/policy.json" + stat: + path: "{{ node_custom_config }}/neutron/policy.json" + delegate_to: localhost run_once: True register: neutron_policy diff --git a/ansible/roles/neutron/tasks/precheck.yml b/ansible/roles/neutron/tasks/precheck.yml index 91bc8dd741..b131b308eb 100644 --- a/ansible/roles/neutron/tasks/precheck.yml +++ b/ansible/roles/neutron/tasks/precheck.yml @@ -18,7 +18,8 @@ - inventory_hostname in groups['neutron-server'] - name: Checking number of network agents - local_action: fail msg="Number of network agents are less than two when enabling agent ha" + fail: + msg: "Number of network agents are less than two when enabling agent ha" changed_when: false run_once: True when: @@ -30,14 +31,16 @@ vars: type_drivers: "{{ neutron_type_drivers.replace(' ', '').split(',') | reject('equalto', '') | list }}" tenant_network_types: "{{ neutron_tenant_network_types.replace(' ', '').split(',') | reject('equalto', '') | list }}" - local_action: fail msg="Tenant network type '{{ item }}' is not in type drivers [{{ neutron_type_drivers }}]" + fail: + msg: "Tenant network type '{{ item }}' is not in type drivers [{{ neutron_type_drivers }}]" changed_when: false when: item not in type_drivers run_once: true with_items: "{{ tenant_network_types }}" - name: Checking whether Ironic enabled - local_action: fail msg="Ironic must be enabled when using networking-baremetal/ironic-neutron-agent" + fail: + msg: "Ironic must be enabled when using networking-baremetal/ironic-neutron-agent" changed_when: false run_once: True when: diff --git a/ansible/roles/nova-cell/tasks/config.yml b/ansible/roles/nova-cell/tasks/config.yml index b82cad315e..b2cf9b9b4a 100644 --- a/ansible/roles/nova-cell/tasks/config.yml +++ b/ansible/roles/nova-cell/tasks/config.yml @@ -36,7 +36,9 @@ - inventory_hostname in groups[nova_cell_compute_group] - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: nova_policy with_first_found: diff --git a/ansible/roles/nova-cell/tasks/external_ceph.yml b/ansible/roles/nova-cell/tasks/external_ceph.yml index 628910ea26..4587452a61 100644 --- a/ansible/roles/nova-cell/tasks/external_ceph.yml +++ b/ansible/roles/nova-cell/tasks/external_ceph.yml @@ -10,7 +10,9 @@ when: inventory_hostname in groups[nova_cell_compute_group] - name: Check nova keyring file - local_action: stat path="{{ node_custom_config }}/nova/ceph.client.nova.keyring" + stat: + path: "{{ node_custom_config }}/nova/ceph.client.nova.keyring" + delegate_to: localhost run_once: True register: nova_cephx_keyring_file failed_when: not nova_cephx_keyring_file.stat.exists @@ -19,7 +21,9 @@ - external_ceph_cephx_enabled | bool - name: Check cinder keyring file - local_action: stat path="{{ node_custom_config }}/nova/ceph.client.cinder.keyring" + stat: + path: "{{ node_custom_config }}/nova/ceph.client.cinder.keyring" + delegate_to: localhost run_once: True register: cinder_cephx_keyring_file failed_when: not cinder_cephx_keyring_file.stat.exists diff --git a/ansible/roles/nova/tasks/config.yml b/ansible/roles/nova/tasks/config.yml index a706e6f085..cd910ed473 100644 --- a/ansible/roles/nova/tasks/config.yml +++ b/ansible/roles/nova/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ nova_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: nova_policy with_first_found: diff --git a/ansible/roles/octavia/tasks/config.yml b/ansible/roles/octavia/tasks/config.yml index 50be6efb00..c2dbbeedd1 100644 --- a/ansible/roles/octavia/tasks/config.yml +++ b/ansible/roles/octavia/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ octavia_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: octavia_policy with_first_found: diff --git a/ansible/roles/octavia/tasks/precheck.yml b/ansible/roles/octavia/tasks/precheck.yml index f6f9e55739..7f2698e1bc 100644 --- a/ansible/roles/octavia/tasks/precheck.yml +++ b/ansible/roles/octavia/tasks/precheck.yml @@ -30,7 +30,9 @@ - inventory_hostname in groups['octavia-health-manager'] - name: Checking certificate files exist for octavia - local_action: stat path="{{ node_custom_config }}/octavia/{{ item }}" + stat: + path: "{{ node_custom_config }}/octavia/{{ item }}" + delegate_to: localhost run_once: True register: result failed_when: not result.stat.exists diff --git a/ansible/roles/panko/tasks/config.yml b/ansible/roles/panko/tasks/config.yml index a70fad4b63..ba808b1754 100644 --- a/ansible/roles/panko/tasks/config.yml +++ b/ansible/roles/panko/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ panko_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: panko_policy with_first_found: diff --git a/ansible/roles/placement/tasks/config.yml b/ansible/roles/placement/tasks/config.yml index 346667f3d0..221c8ae53b 100644 --- a/ansible/roles/placement/tasks/config.yml +++ b/ansible/roles/placement/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ placement_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: placement_policy with_first_found: diff --git a/ansible/roles/prechecks/tasks/package_checks.yml b/ansible/roles/prechecks/tasks/package_checks.yml index ab504fede4..7919b540e6 100644 --- a/ansible/roles/prechecks/tasks/package_checks.yml +++ b/ansible/roles/prechecks/tasks/package_checks.yml @@ -7,6 +7,7 @@ failed_when: result is failed or result.stdout is version(docker_py_version_min, '<') - name: Checking Ansible version - local_action: fail msg="Current Ansible version {{ ansible_version.full }} is less than {{ ansible_version_min }}" + fail: + msg: "Current Ansible version {{ ansible_version.full }} is less than {{ ansible_version_min }}" run_once: true when: ansible_version.full is version(ansible_version_min, '<') diff --git a/ansible/roles/prechecks/tasks/service_checks.yml b/ansible/roles/prechecks/tasks/service_checks.yml index 14b49fed28..2fe630cdca 100644 --- a/ansible/roles/prechecks/tasks/service_checks.yml +++ b/ansible/roles/prechecks/tasks/service_checks.yml @@ -12,7 +12,9 @@ # will pass, but only because nothing in the vault file has the format of a # YAML dict item. - name: Checking empty passwords in passwords.yml. Run kolla-genpwd if this task fails - local_action: command grep '^[^#].*:\s*$' "{{ node_config }}/passwords.yml" + command: + cmd: grep '^[^#].*:\s*$' "{{ node_config }}/passwords.yml" + delegate_to: localhost run_once: True register: result changed_when: false @@ -35,7 +37,8 @@ - name: Validate that internal and external vip address are different when TLS is enabled only on either the internal and external network run_once: True - local_action: fail msg='kolla_external_vip_address and kolla_internal_vip_address must not be the same when only one network has TLS enabled' + fail: + msg: 'kolla_external_vip_address and kolla_internal_vip_address must not be the same when only one network has TLS enabled' changed_when: false when: - kolla_enable_tls_external | bool or kolla_enable_tls_internal | bool diff --git a/ansible/roles/prometheus/tasks/config.yml b/ansible/roles/prometheus/tasks/config.yml index 8386442177..25f95a31a7 100644 --- a/ansible/roles/prometheus/tasks/config.yml +++ b/ansible/roles/prometheus/tasks/config.yml @@ -27,11 +27,11 @@ - name: Find custom prometheus alert rules files become: true - local_action: - module: find + find: path: "{{ node_custom_config }}/prometheus/" pattern: "*.rules" run_once: True + delegate_to: localhost register: prometheus_alert_rules when: - enable_prometheus_alertmanager | bool diff --git a/ansible/roles/qinling/tasks/config.yml b/ansible/roles/qinling/tasks/config.yml index e403b65384..1d5dd75376 100644 --- a/ansible/roles/qinling/tasks/config.yml +++ b/ansible/roles/qinling/tasks/config.yml @@ -18,7 +18,9 @@ - inventory_hostname in groups['qinling-engine'] - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: qinling_policy with_first_found: diff --git a/ansible/roles/rally/tasks/config.yml b/ansible/roles/rally/tasks/config.yml index e5113114e3..baa8f4064f 100644 --- a/ansible/roles/rally/tasks/config.yml +++ b/ansible/roles/rally/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ rally_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: rally_policy with_first_found: diff --git a/ansible/roles/sahara/tasks/config.yml b/ansible/roles/sahara/tasks/config.yml index 3fc1733a61..d3455b888b 100644 --- a/ansible/roles/sahara/tasks/config.yml +++ b/ansible/roles/sahara/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ sahara_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: sahara_policy with_first_found: diff --git a/ansible/roles/searchlight/tasks/config.yml b/ansible/roles/searchlight/tasks/config.yml index 421cc77931..a660cfb50a 100644 --- a/ansible/roles/searchlight/tasks/config.yml +++ b/ansible/roles/searchlight/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ searchlight_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: searchlight_policy with_first_found: diff --git a/ansible/roles/senlin/tasks/config.yml b/ansible/roles/senlin/tasks/config.yml index eba5c5e98e..e1220b31f9 100644 --- a/ansible/roles/senlin/tasks/config.yml +++ b/ansible/roles/senlin/tasks/config.yml @@ -13,7 +13,9 @@ with_dict: "{{ senlin_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" + delegate_to: localhost run_once: True register: senlin_policy with_first_found: diff --git a/ansible/roles/swift/tasks/config.yml b/ansible/roles/swift/tasks/config.yml index 40c757a856..8a70049192 100644 --- a/ansible/roles/swift/tasks/config.yml +++ b/ansible/roles/swift/tasks/config.yml @@ -193,7 +193,9 @@ - "{{ swift_extra_ring_files }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ node_custom_config }}/swift/policy.json" + stat: + path: "{{ node_custom_config }}/swift/policy.json" + delegate_to: localhost run_once: True register: swift_policy diff --git a/ansible/roles/swift/tasks/precheck.yml b/ansible/roles/swift/tasks/precheck.yml index aba043fffd..ba0406a183 100644 --- a/ansible/roles/swift/tasks/precheck.yml +++ b/ansible/roles/swift/tasks/precheck.yml @@ -99,7 +99,9 @@ - name: Checking Swift ring files run_once: True - local_action: stat path="{{ node_custom_config }}/swift/{{ item }}" + stat: + path: "{{ node_custom_config }}/swift/{{ item }}" + delegate_to: localhost register: swift_ring_files with_items: - "account.builder" @@ -112,7 +114,8 @@ - name: Fail if ring files don't exist run_once: True - local_action: fail msg="Swift ring files do not exist. Ensure .builder and .gz are available for each of account/container/object under {{ node_custom_config }}/swift before deploying Swift." + fail: + msg: "Swift ring files do not exist. Ensure .builder and .gz are available for each of account/container/object under {{ node_custom_config }}/swift before deploying Swift." with_items: '{{ swift_ring_files.results }}' when: - item.stat.exists == false diff --git a/ansible/roles/tacker/tasks/config.yml b/ansible/roles/tacker/tasks/config.yml index 4c34fe74a4..6995500fa4 100644 --- a/ansible/roles/tacker/tasks/config.yml +++ b/ansible/roles/tacker/tasks/config.yml @@ -13,8 +13,10 @@ with_dict: "{{ tacker_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: tacker_policy with_first_found: - files: "{{ supported_policy_format_list }}" diff --git a/ansible/roles/trove/tasks/config.yml b/ansible/roles/trove/tasks/config.yml index 0322faf332..7e38e5e462 100644 --- a/ansible/roles/trove/tasks/config.yml +++ b/ansible/roles/trove/tasks/config.yml @@ -13,8 +13,10 @@ with_dict: "{{ trove_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: trove_policy with_first_found: - files: "{{ supported_policy_format_list }}" diff --git a/ansible/roles/vitrage/tasks/config.yml b/ansible/roles/vitrage/tasks/config.yml index 84012fa858..8c8259401a 100644 --- a/ansible/roles/vitrage/tasks/config.yml +++ b/ansible/roles/vitrage/tasks/config.yml @@ -13,8 +13,10 @@ with_dict: "{{ vitrage_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: vitrage_policy with_first_found: - files: "{{ supported_policy_format_list }}" diff --git a/ansible/roles/vitrage/tasks/precheck.yml b/ansible/roles/vitrage/tasks/precheck.yml index 953880ff56..65d2e2ae21 100644 --- a/ansible/roles/vitrage/tasks/precheck.yml +++ b/ansible/roles/vitrage/tasks/precheck.yml @@ -17,7 +17,9 @@ - inventory_hostname in groups['vitrage-api'] - name: Checking custom prometheus_conf.yaml exists - local_action: stat path="{{ node_custom_config }}/vitrage/prometheus_conf.yaml" + stat: + path: "{{ node_custom_config }}/vitrage/prometheus_conf.yaml" + delegate_to: localhost register: result run_once: true failed_when: not result.stat.exists diff --git a/ansible/roles/watcher/tasks/config.yml b/ansible/roles/watcher/tasks/config.yml index b4a0aa86e4..26aef59ab8 100644 --- a/ansible/roles/watcher/tasks/config.yml +++ b/ansible/roles/watcher/tasks/config.yml @@ -13,8 +13,10 @@ with_dict: "{{ watcher_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: watcher_policy with_first_found: - files: "{{ supported_policy_format_list }}" diff --git a/ansible/roles/zun/tasks/config.yml b/ansible/roles/zun/tasks/config.yml index fcff6ccea7..1016b6c9fb 100644 --- a/ansible/roles/zun/tasks/config.yml +++ b/ansible/roles/zun/tasks/config.yml @@ -13,8 +13,10 @@ with_dict: "{{ zun_services }}" - name: Check if policies shall be overwritten - local_action: stat path="{{ item }}" + stat: + path: "{{ item }}" run_once: True + delegate_to: localhost register: zun_policy with_first_found: - files: "{{ supported_policy_format_list }}" diff --git a/ansible/roles/zun/tasks/precheck.yml b/ansible/roles/zun/tasks/precheck.yml index 89fadc8aec..d862f9c810 100644 --- a/ansible/roles/zun/tasks/precheck.yml +++ b/ansible/roles/zun/tasks/precheck.yml @@ -30,8 +30,9 @@ - inventory_hostname in groups['zun-wsproxy'] - name: Ensure kuryr enabled for zun + fail: + msg: "kuryr is required but not enabled" run_once: True - local_action: fail msg="kuryr is required but not enabled" changed_when: false when: - enable_zun | bool diff --git a/tools/validate-all-file.py b/tools/validate-all-file.py index 2d87b16449..6acbc08a72 100755 --- a/tools/validate-all-file.py +++ b/tools/validate-all-file.py @@ -172,13 +172,19 @@ def check_docker_become(): "task %s in %s", module, task['name'], fullpath) for module in cmd_modules: - if (module in task and - task[module].startswith('docker') and - not task.get('become')): - return_code = 1 - LOG.error("Use of docker in %s module without " - "become in task %s in %s", - module, task['name'], fullpath) + docker_without_become = False + if (module in task and not task.get('become')): + if (isinstance(task[module], str) and + (task[module]).startswith('docker')): + docker_without_become = True + if (isinstance(task[module], dict) and + task[module]['cmd'].startswith('docker')): + docker_without_become = True + if docker_without_become: + return_code = 1 + LOG.error("Use of docker in %s module without " + "become in task %s in %s", + module, task['name'], fullpath) return return_code