Delegate from first available compute host

The 'Drop authorized keys file script locally' task shouldn't
specifically require that the first member of the nova_compute group be
available. If the playbook is run with a limit excluding that host, the
task will always end up being skipped.

Use an intersect filter to find the first available compute host within
the play and use that as the delegation host.

Closes-Bug: 1632447
Change-Id: Id12fd6cee104a6fb705acc66704f21d629694d84
(cherry picked from commit 3f91e25a0a)
This commit is contained in:
Jimmy McCrory 2016-10-11 17:57:28 -07:00 committed by Jesse Pretorius (odyssey4me)
parent 42c428496c
commit 4813e76b92
1 changed files with 8 additions and 1 deletions

View File

@ -13,6 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Determine first available nova compute host
set_fact:
first_available_compute: "{{ groups['nova_compute'] | intersect(play_hosts) | first }}"
tags:
- nova-key
- nova-key-distribute
# The authorized key file script will be generated locally and copied to all known
# compute hosts within the environment. This script will add a key to the nova
# user's .ssh/authorized_keys file if it's not already found.
@ -22,7 +29,7 @@
dest: "/var/tmp/openstack-nova-key.sh"
mode: "0755"
delegate_to: localhost
when: inventory_hostname == groups['nova_compute'][0]
when: inventory_hostname == first_available_compute
tags:
- nova-key
- nova-key-distribute