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: I7c4c7e6887cc756998ce028355402705a45e18ed
This commit is contained in:
Dmitriy Rabotjagov 2019-06-21 15:53:16 +03:00 committed by Dmitriy Rabotyagov (noonedeadpunk)
parent 0475d4218e
commit 373e2d3042
2 changed files with 6 additions and 13 deletions

View File

@ -33,7 +33,7 @@
- zun-install - zun-install
- name: Install the python venv - name: Install the python venv
include_role: import_role:
name: "python_venv_build" name: "python_venv_build"
vars: vars:
venv_build_constraints: "{{ zun_git_constraints }}" venv_build_constraints: "{{ zun_git_constraints }}"
@ -101,7 +101,7 @@
- zun-config - zun-config
- name: Run the systemd service role - name: Run the systemd service role
include_role: import_role:
name: systemd_service name: systemd_service
vars: vars:
systemd_user_name: "{{ zun_system_user_name }}" systemd_user_name: "{{ zun_system_user_name }}"
@ -113,16 +113,7 @@
systemd_BlockIOAccounting: true systemd_BlockIOAccounting: true
systemd_MemoryAccounting: true systemd_MemoryAccounting: true
systemd_TasksAccounting: true systemd_TasksAccounting: true
systemd_services: systemd_services: "{{ filtered_zun_services }}"
- service_name: "{{ service_var.service_name }}"
enabled: yes
state: started
execstarts: "{{ service_var.execstarts }}"
execreloads: "{{ service_var.execreloads | default([]) }}"
config_overrides: "{{ zun_service_defaults | combine(service_var.init_config_overrides) }}"
with_items: "{{ filtered_zun_services }}"
loop_control:
loop_var: service_var
tags: tags:
- zun-config - zun-config
- systemd-service - systemd-service

View File

@ -23,7 +23,9 @@ filtered_zun_services: |-
{% if (value['group'] in group_names) and {% if (value['group'] in group_names) and
(('condition' not in value) or (('condition' not in value) or
('condition' in value and value['condition'])) %} ('condition' in value and value['condition'])) %}
{% set _ = value.update({'service_key': key}) %} {% set _ = value.update({'enabled': 'yes', 'state': 'started'}) %}
{% set _ = value.update({'config_overrides': (zun_service_defaults | combine(value.init_config_overrides))}) %}
{% set _ = value.pop('init_config_overrides') %}
{% set _ = services.append(value) %} {% set _ = services.append(value) %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}