Convert dynamic includes to static imports

When task/role files are included using include_tasks, tags are not
passed to the included tasks. As a result, tags like neutron-config
do not have the intended effect. This patch changes include_tasks
to import_tasks for all cases where dynamic vars or loops are not used
so that tags are properly handled.

Reference -
https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse.html
https://bugs.launchpad.net/openstack-ansible/+bug/1815043

Change-Id: I2492ed205a94541160e72a9cb3631e0b255d5b53
This commit is contained in:
Dmitriy Rabotyagov 2019-07-16 20:21:57 +03:00
parent 0075b90198
commit 480d74bb71
2 changed files with 18 additions and 17 deletions

View File

@ -79,20 +79,20 @@
- common-mq
- aodh-config
- include_tasks: aodh_pre_install.yml
- import_tasks: aodh_pre_install.yml
tags:
- aodh-install
- include_tasks: aodh_install.yml
- import_tasks: aodh_install.yml
tags:
- aodh-install
- include_tasks: aodh_post_install.yml
- import_tasks: aodh_post_install.yml
tags:
- aodh-config
- name: Run the systemd service role
include_role:
import_role:
name: systemd_service
vars:
systemd_user_name: "{{ aodh_system_user_name }}"
@ -104,30 +104,22 @@
systemd_BlockIOAccounting: true
systemd_MemoryAccounting: true
systemd_TasksAccounting: true
systemd_services:
- service_name: "{{ service_var.service_name }}"
enabled: yes
state: started
execstarts: "{{ service_var.execstarts }}"
config_overrides: "{{ service_var.init_config_overrides }}"
with_items: "{{ filtered_aodh_services }}"
loop_control:
loop_var: service_var
systemd_services: "{{ filtered_aodh_services }}"
tags:
- aodh-config
- systemd-service
- include_tasks: aodh_db_sync.yml
- import_tasks: aodh_db_sync.yml
when:
- inventory_hostname == groups['aodh_all'][0]
tags:
- aodh-config
- include_tasks: aodh_apache.yml
- import_tasks: aodh_apache.yml
tags:
- aodh-config
- include_tasks: aodh_service_setup.yml
- import_tasks: aodh_service_setup.yml
when:
- inventory_hostname == groups['aodh_all'][0]
tags:

View File

@ -17,7 +17,16 @@ filtered_aodh_services: |-
{% set services = [] %}
{% for key, value in aodh_services.items() %}
{% if (value['group'] in group_names) %}
{% set _ = value.update({'service_key': key}) %}
{% set _ = value.update(
{
'service_key': key,
'enabled': 'yes',
'state': 'started',
'config_overrides': value.init_config_overrides
}
)
%}
{% set _ = value.pop('init_config_overrides') -%}
{% set _ = services.append(value) %}
{% endif %}
{% endfor %}