From 54bbab95034240938c00e9d6b24d917db886eb75 Mon Sep 17 00:00:00 2001 From: Roberto Alfieri Date: Wed, 25 Sep 2024 18:19:25 +0200 Subject: [PATCH] Gather ssh private key from the hostvars in ceph playbook --- playbooks/ceph.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/playbooks/ceph.yml b/playbooks/ceph.yml index 0a2bea363b..e39dad303d 100644 --- a/playbooks/ceph.yml +++ b/playbooks/ceph.yml @@ -58,7 +58,7 @@ - name: Distribute SSH keypair to target nodes tags: admin - hosts: "{{ cifmw_ceph_target | default('computes') }}" + hosts: "{{ cifmw_ceph_target | default('computes') }}" gather_facts: false become: true vars: @@ -265,7 +265,12 @@ gather_facts: false vars: _target_hosts: "{{ groups[cifmw_ceph_target | default('computes')] | default([]) }}" - ansible_ssh_private_key_file: "{{ lookup('env', 'ANSIBLE_SSH_PRIVATE_KEY') }}" + _target: "{{ _target_hosts | first }}" + ansible_ssh_private_key_file: >- + {{ + hostvars[_target]['ansible_ssh_private_key_file'] | + default(lookup('env', 'ANSIBLE_SSH_PRIVATE_KEY')) + }} cifmw_cephadm_spec_ansible_host: /tmp/ceph_spec.yml cifmw_cephadm_bootstrap_conf: /tmp/initial_ceph.conf cifmw_ceph_client_vars: /tmp/ceph_client.yml