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] cf0c25c37d
[1] https://review.openstack.org/#/c/369212/
[2] c68c9d95fc
[3] 423e3f3fdf
[4] https://review.openstack.org/#/c/355861

TrivialFix
Closes-Bug: #1628472

Change-Id: Ia94146579e743935501f1ff4b4c1bf6cb7c43aa3
This commit is contained in:
Andrew Widdersheim 2016-09-26 09:37:11 -04:00
parent a9190021ab
commit 4963898b21
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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,