From 56ee4fe9285689e369e7d551bc7f718f0a076e6b Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 7 Aug 2019 19:27:25 +0300 Subject: [PATCH] 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 --- tasks/main.yml | 37 ++++++++++++++----------------------- vars/main.yml | 10 +++++++++- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 5e02fae8..e7148f4d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 diff --git a/vars/main.yml b/vars/main.yml index 1f142b49..4d9bb207 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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 %}