From 21ce37e6984b47c971468bc576708214e9786631 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 17 Aug 2018 13:44:42 +0100 Subject: [PATCH] Fixes for baremetal compute commands Gather facts prior to using the stackhpc.os-shade role. This is required following a recent change in that role to reference the ansible_user_uid and ansible_user_gid facts. Allow 'kayobe baremetal compute rename' command to ignore compute nodes in the ansible inventory but not found in ironic. Change-Id: I75a2f0dd0192e41de7b91376bb32b4149df04a60 TrivialFix --- ansible/baremetal-compute-inspect.yml | 2 +- ansible/baremetal-compute-manage.yml | 2 +- ansible/baremetal-compute-provide.yml | 2 +- ansible/baremetal-compute-rename.yml | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ansible/baremetal-compute-inspect.yml b/ansible/baremetal-compute-inspect.yml index 8b356c17a..9474d2b54 100644 --- a/ansible/baremetal-compute-inspect.yml +++ b/ansible/baremetal-compute-inspect.yml @@ -8,7 +8,7 @@ - name: Ensure dependencies are installed and the virtual environment is activated hosts: controllers[0] - gather_facts: False + gather_facts: true vars: venv: "{{ virtualenv_path }}/shade" roles: diff --git a/ansible/baremetal-compute-manage.yml b/ansible/baremetal-compute-manage.yml index 326840171..7f9d1f7ef 100644 --- a/ansible/baremetal-compute-manage.yml +++ b/ansible/baremetal-compute-manage.yml @@ -8,7 +8,7 @@ - name: Ensure baremetal compute nodes are available in ironic hosts: controllers[0] - gather_facts: False + gather_facts: true vars: venv: "{{ virtualenv_path }}/shade" roles: diff --git a/ansible/baremetal-compute-provide.yml b/ansible/baremetal-compute-provide.yml index 2d578e0f2..b51a37c5b 100644 --- a/ansible/baremetal-compute-provide.yml +++ b/ansible/baremetal-compute-provide.yml @@ -8,7 +8,7 @@ - name: Ensure baremetal compute nodes are available in ironic hosts: controllers[0] - gather_facts: False + gather_facts: true vars: venv: "{{ virtualenv_path }}/shade" roles: diff --git a/ansible/baremetal-compute-rename.yml b/ansible/baremetal-compute-rename.yml index 5fdc4958e..049cba620 100644 --- a/ansible/baremetal-compute-rename.yml +++ b/ansible/baremetal-compute-rename.yml @@ -54,5 +54,8 @@ # be respected when using delegate_to. ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" ipmi_address: "{{ hostvars[inventory_hostname].ipmi_address }}" - node: "{{ (nodes.stdout | from_json) | selectattr('Driver Info.ipmi_address', 'equalto', ipmi_address) | first }}" - when: node['Name'] != inventory_hostname + matching_nodes: "{{ (nodes.stdout | from_json) | selectattr('Driver Info.ipmi_address', 'defined') | selectattr('Driver Info.ipmi_address', 'equalto', ipmi_address) | list }}" + node: "{{ matching_nodes | first }}" + when: + - matching_nodes | length > 0 + - node['Name'] != inventory_hostname