From 6e74637fcdc5084abc7c9dfcebbd4f98e043dde4 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Tue, 4 Jul 2017 13:43:28 +0100 Subject: [PATCH] Switch from run_once back to inventory scoping As it turns out, run_once executes a task once per batch when executed from a serialised playbook instead of once per set of play hosts as previously thought. In this patch we implement a combination of dynamic inclusion, inventory scoping and play host scoping to achieve the required goal of only running it once, even when the playbook is executed using limits. We also remove the unnecessary extra local fact refresh. Change-Id: Ib864bf2c0603e8281aa0ba3979ae020e90fd0adc --- tasks/main.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 5b593081..b60d6ff7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -49,19 +49,18 @@ - glance-config - include: glance_db_setup.yml - run_once: true + static: no + when: + - "'glance_api' in group_names" + - "inventory_hostname == ansible_play_hosts[0]" tags: - glance-config - include: glance_service_setup.yml - run_once: true - tags: - - glance-config - -- name: refresh local facts - setup: - filter: ansible_local - gather_subset: "!all" + static: no + when: + - "'glance_api' in group_names" + - "inventory_hostname == ansible_play_hosts[0]" tags: - glance-config