From 1a6bd0c34069b5da1ad235ee81421acee5baf894 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Thu, 28 Mar 2019 11:24:19 +1300 Subject: [PATCH] Use discovered private key file If {{playbook_dir}}/ssh_private_key exists then this will be used as the --private-key argument. This avoids the assumption that ceph-ansible should use the same private key as ansible is currently running under. Change-Id: I33c701e72196086e1f78cb09affaf9d7dcd131c6 Related-Bug: #1813832 --- deployment/ceph-ansible/ceph-base.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/deployment/ceph-ansible/ceph-base.yaml b/deployment/ceph-ansible/ceph-base.yaml index c2e08339ea..f7bff37344 100644 --- a/deployment/ceph-ansible/ceph-base.yaml +++ b/deployment/ceph-ansible/ceph-base.yaml @@ -466,6 +466,14 @@ outputs: when: step == '2' tags: ceph block: + - name: detect private key file + stat: + path: "{{playbook_dir}}/ssh_private_key" + register: detect_private_key_file + - name: set private key file + set_fact: + ceph_ansible_private_key_file: "{{playbook_dir}}/ssh_private_key" + when: ceph_ansible_private_key_file is not defined and detect_private_key_file.stat.exists - name: run nodes-uuid # needs become to be able to read the ssh private key become: true @@ -477,7 +485,7 @@ outputs: - ANSIBLE_CONFIG="{{playbook_dir}}/ansible.cfg" - ANSIBLE_REMOTE_TEMP=/tmp/nodes_uuid_tmp - ansible-playbook - - '{% if ansible_ssh_private_key_file is defined %}--private-key {{ansible_ssh_private_key_file}}{% endif %}' + - '{% if ceph_ansible_private_key_file is defined %}--private-key {{ceph_ansible_private_key_file}}{% endif %}' - '-i' - '{{playbook_dir}}/ceph-ansible/inventory.yml' - '{% if ansible_python_interpreter is defined %}-e ansible_python_interpreter={{ansible_python_interpreter}}{% endif %}' @@ -569,7 +577,7 @@ outputs: data: {get_param: CephAnsibleEnvironmentVariables} expression: $.data.items().select($[0] + '=' + $[1]).join(' ') - ansible-playbook - - '{% if ansible_ssh_private_key_file is defined %}--private-key {{ansible_ssh_private_key_file}}{% endif %}' + - '{% if ceph_ansible_private_key_file is defined %}--private-key {{ceph_ansible_private_key_file}}{% endif %}' - '{% if ansible_python_interpreter is defined %}-e ansible_python_interpreter={{ansible_python_interpreter}}{% endif %}' - '-{%- for number in range(0, ceph_ansible_playbook_verbosity) -%}v{% endfor %}' - if: