Fix multi arch repo-build

The existing multi arch repo build is broken because the add_host module
bypasses the host play loop of ansible and is only executed on the first
host. To excute on multiple hosts the 'with_' directive must be used.
The result of the existing code is that the repo_nodes group is always
empty because the first host is always skipped by the when clause.

Change-Id: I2c37217a78c006ae28a4f31f3d86244ef4df60be
Closes-Bug: #1641410
This commit is contained in:
Kyle L. Henderson 2016-11-13 08:08:50 -06:00
parent ed95267fd1
commit 1e0c11f416

@ -21,14 +21,21 @@
key: repo_servers_{{ ansible_architecture }}
tags:
- always
# Use the 'add_host' module to create the repo_nodes group. The add_hosts module
# bypasses the play host loop of ansible and runs only once referencing the first
# host. To run it on each host we have to use with_items. Also note, we have
# to manually lookup the ansible_architecture for the 'item' host.
- name: Prepare group of master repo servers
local_action:
module: "add_host"
name: "{{ item }}"
name: "{{ groups['repo_servers_' + hostvars[item].ansible_architecture][0] }}"
groups: "repo_nodes"
# Process all nodes that don't match the architecture of repo_all[0]
when:
- item != groups['repo_all'][0]
with_items: "{{ groups['repo_servers_' + ansible_architecture][0] }}"
- hostvars[item].ansible_architecture != hostvars[groups['repo_all'][0]].ansible_architecture
with_items:
- "{{ groups['repo_all'][1:] }}"
tags:
- repo-build