Make ceph-ansible run handle missing "{{ playbook_dir }}/ssh_key"

The SSH private key will normally be in $HOME/.ssh/id_rsa_tripleo
so if that key is present, then use it. This is a more reliable
location than "{{ playbook_dir }}/ssh_key", which will go away
with Mistral. This change is also backwards compatible as it
will fall back to using "{{ playbook_dir }}/ssh_key" in the case
that $HOME/.ssh/id_rsa_tripleo is missing. Covers one extra case
where CephAnsibleEnvironmentVariables/ANSIBLE_PRIVATE_KEY_FILE
might have been needed.

Also switches nodes_uuid_command to use ceph-ansible's ansible.cfg as
config-download may not always provide "{{ playbook_dir }}/ansible.cfg"

Change-Id: Ic7e20844877492d7c4b85f7579e90f6c9de355ec
Closes-Bug: #1868864
This commit is contained in:
John Fulton 2020-03-24 20:13:36 +00:00
parent 9c873191d7
commit eaa13ee254
2 changed files with 22 additions and 4 deletions

View File

@ -19,7 +19,7 @@
nodes_uuid_list:
- ANSIBLE_LOG_PATH="{{ playbook_dir }}/ceph-ansible/nodes_uuid_command.log"
- ANSIBLE_SSH_CONTROL_PATH_DIR="{{ playbook_dir }}/ceph-ansible/"
- ANSIBLE_CONFIG="{{ playbook_dir }}/ansible.cfg"
- ANSIBLE_CONFIG=/usr/share/ceph-ansible/ansible.cfg
- ANSIBLE_REMOTE_TEMP=/tmp/nodes_uuid_tmp
- "{{ calling_ansible_environment_variables|join(' ') }}"
- "{{ ceph_ansible_environment_variables|join(' ') }}"

View File

@ -14,17 +14,35 @@
# License for the specific language governing permissions and limitations
# under the License.
- name: detect private key file
- name: detect private key file in $HOME/.ssh/id_rsa_tripleo
# needs become to be able to read the ssh private key
become: true
stat:
path: "{{ playbook_dir }}/ssh_private_key"
path: "{{ lookup('env','HOME') }}/.ssh/id_rsa_tripleo"
register: detect_private_key_file
- name: set private key file
# needs become to be able to read the ssh private key
become: true
set_fact:
ceph_ansible_private_key_file: "{{ playbook_dir }}/ssh_private_key"
ceph_ansible_private_key_file: "{{ lookup('env','HOME') }}/.ssh/id_rsa_tripleo"
when:
- detect_private_key_file.stat.exists | bool
- name: Falling back to looking for ssh_private_key in playbook_dir
when: ceph_ansible_private_key_file is undefined
block:
- name: detect private key file in playbook_dir
# needs become to be able to read the ssh private key
become: true
stat:
path: "{{ playbook_dir }}/ssh_private_key"
register: detect_private_key_file
- name: set private key file
# needs become to be able to read the ssh private key
become: true
set_fact:
ceph_ansible_private_key_file: "{{ playbook_dir }}/ssh_private_key"
when:
- detect_private_key_file.stat.exists | bool