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 swift-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: I447c0096708c50c2a3b003af84ca7af4dd72c5f5
This commit is contained in:
Dmitriy Rabotyagov 2019-08-07 19:27:25 +03:00
parent a18639c4e8
commit 56ee4fe928
2 changed files with 23 additions and 24 deletions

View File

@ -74,7 +74,7 @@
- common-mq
- octavia-config
- include_tasks: octavia_certs.yml
- import_tasks: octavia_certs.yml
run_once: true
when: octavia_generate_certs | bool
tags:
@ -85,20 +85,20 @@
tags:
- always
- include_tasks: octavia_pre_install.yml
- import_tasks: octavia_pre_install.yml
tags:
- octavia-install
- include_tasks: octavia_install.yml
- import_tasks: octavia_install.yml
tags:
- octavia-install
- include_tasks: octavia_uwsgi.yml
- import_tasks: octavia_uwsgi.yml
tags:
- octavia-config
- name: Run the systemd service role
include_role:
import_role:
name: systemd_service
vars:
systemd_after_targets: "{{ service_var.after_targets | default(['syslog.target', 'network.target']) }}"
@ -111,26 +111,17 @@
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_octavia_services }}"
loop_control:
loop_var: service_var
systemd_services: "{{ filtered_octavia_services }}"
tags:
- nova-config
- systemd-service
- include_tasks: octavia_service_add.yml
- import_tasks: octavia_service_add.yml
run_once: true
tags:
- octavia-install
- include_tasks: octavia_mgmt_network.yml
- import_tasks: octavia_mgmt_network.yml
when:
- octavia_neutron_management_network_uuid is not defined
- octavia_neutron_management_network_name is defined
@ -138,35 +129,35 @@
- octavia-install
- octavia-config
- include_tasks: octavia_security_group.yml
- import_tasks: octavia_security_group.yml
run_once: true
tags:
- octavia-install
- include_tasks: octavia_flavor_create.yml
- import_tasks: octavia_flavor_create.yml
when:
- octavia_nova_flavor_uuid is not defined
tags:
- octavia-install
- octavia-config
- include_tasks: octavia_post_install.yml
- import_tasks: octavia_post_install.yml
tags:
- octavia-install
- octavia-config
- include_tasks: octavia_db_sync.yml
- import_tasks: octavia_db_sync.yml
when:
- inventory_hostname == groups['octavia_all'][0]
tags:
- octavia-install
- include_tasks: octavia_policy.yml
- import_tasks: octavia_policy.yml
tags:
- octavia-install
- octavia-config
- include_tasks: octavia_amp_image.yml
- import_tasks: octavia_amp_image.yml
run_once: true
tags:
- octavia-config

View File

@ -23,7 +23,15 @@ filtered_octavia_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',
'config_overrides': value.init_config_overrides
}
)
%}
{% set _ = value.pop('init_config_overrides') %}
{% set _ = services.append(value) %}
{% endif %}
{% endfor %}