From 768b47ab292979f37ffd03871ec5af70f4114b5e Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 21 Sep 2016 18:51:59 +0100 Subject: [PATCH] Force Ansible to use dynamic includes Ansible 2.1.1 introduces a regression in the way conditional includes are handled which results in every task in the included file being evaluated even if the condition for the include is not met. This extends the run time significantly for a deployment. This patch forces all conditional includes which are not inventory based to be dynamic. Change-Id: Ied462a7b79cb2d6615e110484ea734e136f59034 Related-Bug: https://github.com/ansible/ansible/issues/17687 --- tasks/main.yml | 16 ++++++++-------- tasks/swift_init_common.yml | 2 ++ tasks/swift_install.yml | 5 +++-- tasks/swift_rings.yml | 9 +++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index fd72b72f..383ae6c6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,8 +39,8 @@ # Check the swift_hash_path_* variables haven't changed - include: swift_check_hashes.yml - when: - - not swift_force_change_hashes | bool + static: no + when: not swift_force_change_hashes | bool tags: - swift-config @@ -107,20 +107,20 @@ meta: flush_handlers - include: swift_key_setup.yml - when: - - swift_do_sync | bool + static: no + when: swift_do_sync | bool tags: - swift-config - include: swift_rings.yml - when: - - swift_do_sync | bool + static: no + when: swift_do_sync | bool tags: - swift-install - swift-config - include: swift_sync_post_install.yml - when: - - swift_do_sync | bool + static: no + when: swift_do_sync | bool tags: - always diff --git a/tasks/swift_init_common.yml b/tasks/swift_init_common.yml index 53ae442d..43d1aade 100644 --- a/tasks/swift_init_common.yml +++ b/tasks/swift_init_common.yml @@ -14,9 +14,11 @@ # limitations under the License. - include: swift_init_upstart.yml + static: no when: pid1_name == "init" - include: swift_init_systemd.yml + static: no when: pid1_name == "systemd" - name: Load service diff --git a/tasks/swift_install.yml b/tasks/swift_install.yml index 8066c2b9..b0024ae8 100644 --- a/tasks/swift_install.yml +++ b/tasks/swift_install.yml @@ -14,8 +14,8 @@ # limitations under the License. - include: install-apt.yml - when: - - ansible_pkg_mgr == 'apt' + static: no + when: ansible_pkg_mgr == 'apt' - name: Create developer mode constraint file copy: @@ -157,4 +157,5 @@ - swift_get_venv | success - include: swift_pypy_setup.yml + static: no when: swift_pypy_enabled | bool diff --git a/tasks/swift_rings.yml b/tasks/swift_rings.yml index 3d25b02b..4d25e5db 100644 --- a/tasks/swift_rings.yml +++ b/tasks/swift_rings.yml @@ -16,17 +16,14 @@ - include: swift_rings_md5sum.yml - include: swift_rings_check.yml - when: > - inventory_hostname == groups['swift_hosts'][0] + when: inventory_hostname == groups['swift_hosts'][0] - include: swift_rings_build.yml - when: > - inventory_hostname == groups['swift_hosts'][0] + when: inventory_hostname == groups['swift_hosts'][0] - include: swift_rings_distribute.yml - include: swift_rings_md5sum.yml - include: swift_rings_post_distribution_check.yml - when: > - inventory_hostname == groups['swift_hosts'][0] + when: inventory_hostname == groups['swift_hosts'][0]