Merge "Improve deployer UX by limiting failure output potential"

This commit is contained in:
Zuul 2020-05-19 19:44:12 +00:00 committed by Gerrit Code Review
commit 4162446148
1 changed files with 59 additions and 44 deletions

View File

@ -87,8 +87,21 @@
ssh_key_file: "{{ ansible_home }}/.ssh/id_rsa" ssh_key_file: "{{ ansible_home }}/.ssh/id_rsa"
become: true become: true
- name: Stat key file
stat:
path: "{{ defined_user_private_key_file }}"
register: key_check
- name: Key block - name: Key block
when:
- user_public_key is undefined
- user_private_key is undefined
- user_private_key_file is undefined
block:
- name: Read key block
run_once: true run_once: true
when:
- key_check.stat.exists | bool
block: block:
- name: Get local private key - name: Get local private key
slurp: slurp:
@ -107,7 +120,12 @@
user_public_key: "{{ public_key_get['content'] | b64decode }}" user_public_key: "{{ public_key_get['content'] | b64decode }}"
user_private_key: "{{ private_key_get['content'] | b64decode }}" user_private_key: "{{ private_key_get['content'] | b64decode }}"
user_private_key_file: "{{ defined_user_private_key_file }}" user_private_key_file: "{{ defined_user_private_key_file }}"
rescue:
- name: Read and create key block
run_once: true
when:
- not (key_check.stat.exists | bool)
block:
- name: Get local private key - name: Get local private key
slurp: slurp:
src: "{{ ansible_home }}/.ssh/id_rsa" src: "{{ ansible_home }}/.ssh/id_rsa"
@ -120,25 +138,22 @@
register: public_key_get register: public_key_get
become: true become: true
- name: Set key facts
set_fact:
user_public_key: "{{ public_key_get['content'] | b64decode }}"
user_private_key: "{{ private_key_get['content'] | b64decode }}"
- name: Write tripleo private key - name: Write tripleo private key
copy: copy:
content: "{{ user_private_key }}" content: "{{ private_key_get['content'] | b64decode }}"
dest: "{{ defined_user_private_key_file }}" dest: "{{ defined_user_private_key_file }}"
mode: "0600" mode: "0600"
- name: Write tripleo public key - name: Write tripleo public key
copy: copy:
content: "{{ user_public_key }}" content: "{{ public_key_get['content'] | b64decode }}"
dest: "{{ defined_user_private_key_file }}.pub" dest: "{{ defined_user_private_key_file }}.pub"
mode: "0640" mode: "0640"
- name: Set key file fact - name: Set key file fact
set_fact: set_fact:
user_public_key: "{{ public_key_get['content'] | b64decode }}"
user_private_key: "{{ private_key_get['content'] | b64decode }}"
user_private_key_file: "{{ defined_user_private_key_file }}" user_private_key_file: "{{ defined_user_private_key_file }}"
- name: Ensure user can ssh to localhost - name: Ensure user can ssh to localhost