From 1e0c11f4165d8e74c028e5e439b93ca083e1515d Mon Sep 17 00:00:00 2001 From: "Kyle L. Henderson" Date: Sun, 13 Nov 2016 08:08:50 -0600 Subject: [PATCH] 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 --- playbooks/repo-build.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/playbooks/repo-build.yml b/playbooks/repo-build.yml index 7e92ce60ad..fc57ae3a40 100644 --- a/playbooks/repo-build.yml +++ b/playbooks/repo-build.yml @@ -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