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
This commit is contained in:
Steve Baker 2019-03-28 11:24:19 +13:00
parent 6de5de2590
commit 1a6bd0c340
1 changed files with 10 additions and 2 deletions

View File

@ -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: