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: I3a1fe5e065b9dbb218acdab06c1d1dac38ea7e64
This commit is contained in:
Dmitriy Rabotyagov 2019-07-17 16:19:27 +03:00
parent e587a89f0e
commit bef0ec0ce2
2 changed files with 17 additions and 17 deletions

View File

@ -57,7 +57,7 @@
- common-mq
- magnum-config
- include_tasks: magnum_pre_install.yml
- import_tasks: magnum_pre_install.yml
tags:
- magnum-install
@ -78,12 +78,12 @@
tags:
- magnum-install
- include_tasks: magnum_post_install.yml
- import_tasks: magnum_post_install.yml
tags:
- magnum-config
- name: Run the systemd service role
include_role:
import_role:
name: systemd_service
vars:
systemd_user_name: "{{ magnum_system_user_name }}"
@ -95,30 +95,21 @@
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 }}"
execreloads: "{{ service_var.execreloads | default([]) }}"
config_overrides: "{{ service_var.init_config_overrides }}"
with_items: "{{ filtered_magnum_services }}"
loop_control:
loop_var: service_var
systemd_services: "{{ filtered_magnum_services }}"
tags:
- magnum-config
- systemd-service
- include_tasks: magnum_db_sync.yml
- import_tasks: magnum_db_sync.yml
when: inventory_hostname == groups['magnum_all'][0]
tags:
- magnum-config
- include_tasks: magnum_uwsgi.yml
- import_tasks: magnum_uwsgi.yml
tags:
- magnum-config
- include_tasks: magnum_service_setup.yml
- import_tasks: magnum_service_setup.yml
when: inventory_hostname == groups['magnum_all'][0]
tags:
- magnum-config

View File

@ -25,7 +25,16 @@ filtered_magnum_services: |-
{% if (value['group'] in group_names) and
(('condition' not in value) or
('condition' in value and value['condition'])) %}
{% 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 %}