From 4963898b21d407a6e702c39f7576b817c5d24119 Mon Sep 17 00:00:00 2001 From: Andrew Widdersheim Date: Mon, 26 Sep 2016 09:37:11 -0400 Subject: [PATCH] Remove redundant common play and add haproxy hosts In cf0c25c37 [0] a play was added to run the common role against all hosts. This ends up being redundant since every role includes the common role as a dependancy. The reasoning behind this change as pointed out by the author in the review comments [1] was so that an operator could run with '--tags common' and just have the common role applied. To avoid redundancy, the common play has been removed and tags have been added to the common role. This allows for just the common role to run when another role is including it while reducing redundancy. A side affect of removing the common playbook which runs against all hosts is that not all facts on all hosts are gathered at the beginning of the site.yml. This breaks the haproxy role since it relies heavily on facts to build out the haproxy.cfg file. Previously, the haproxy role would include several hosts purely for fact gathering purposes as pointed out in c68c9d95 [2] and a guard was put in place so that the tasks would only run against the 'haproxy' group. In 423e3f3f [3] these hosts were removed. After reading the review [4], this seems to have been done without fully understanding why the hosts were there in the first place. This change did not break anything however since the common role that ran on all hosts mentioned previously would gather all of the facts necessary. To fix this fact gathering issue replace the common role play with a play that will simply gather facts with an 'always' tag to ensure it is run regardless of what might be passed in the '--tags' argument by the operator. Kudos to Paul Bourke for helping identify many of these issues. [0] https://github.com/openstack/kolla/commit/cf0c25c37d4dd901a839a12247212c22493e1409 [1] https://review.openstack.org/#/c/369212/ [2] https://github.com/openstack/kolla/commit/c68c9d95fca6485c79a607b3716a88e284c7a64e [3] https://github.com/openstack/kolla/commit/423e3f3fdf07f40b46fed1125076880660d14c53 [4] https://review.openstack.org/#/c/355861 TrivialFix Closes-Bug: #1628472 Change-Id: Ia94146579e743935501f1ff4b4c1bf6cb7c43aa3 --- ansible/roles/common/tasks/main.yml | 2 ++ ansible/site.yml | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index e261f83ee5..c65c9e8588 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -1,8 +1,10 @@ --- - include: "{{ action }}.yml" + tags: common when: not common_run - name: Registering common role has run set_fact: common_run: True + tags: common when: not common_run diff --git a/ansible/site.yml b/ansible/site.yml index 526303236d..dbe0f757cc 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -1,10 +1,17 @@ --- -- hosts: +# NOTE(awiddersheim): Gather facts for all hosts as a +# first step since several plays below require them when +# building their configurations. The below 'gather_facts' +# set to 'false' is a bit confusing but this is to avoid +# Ansible gathering facts twice. +- name: Gather facts for all hosts + hosts: - all serial: '{{ serial|default("0") }}' - roles: - - { role: common, - tags: common } + gather_facts: false + tasks: + - setup: + tags: always - hosts: - ceph-mon @@ -45,7 +52,8 @@ tags: telegraf, when: enable_telegraf | bool } -- hosts: haproxy +- hosts: + - haproxy roles: - { role: haproxy, tags: haproxy,