bifrost-configdrives-dynamic: automatically find ed25519 SSH keys
Also make the SSH key detection code a bit more readable. Change-Id: Ia365f75d7fac3d64d8dce898ca854149c0aeed6e
This commit is contained in:
parent
3823944c76
commit
d550a1f7c4
@ -6,7 +6,7 @@
|
||||
write_interfaces_file: false
|
||||
http_boot_folder: /httpboot
|
||||
# Default location to the ssh public key for the user operating Bifrost.
|
||||
ssh_public_key_path: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa.pub"
|
||||
#ssh_public_key_path: "/path/to/id_rsa.pub"
|
||||
|
||||
# Default interface name
|
||||
# TODO(TheJulia): Remove this default.
|
||||
|
@ -12,18 +12,32 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
---
|
||||
- name: "Defined ssh_public_key_path - Check to see if there is a file where the ssh_public_key_path is defined"
|
||||
stat:
|
||||
path: "{{ ssh_public_key_path }}"
|
||||
register: test_ssh_public_key_path
|
||||
when: ssh_public_key_path is defined
|
||||
- block:
|
||||
- name: "Find a suitable SSH public key"
|
||||
set_fact:
|
||||
ssh_public_key_path: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ lookup('env', 'HOME') }}/.ssh/id_rsa.pub"
|
||||
- "{{ lookup('env', 'HOME') }}/.ssh/id_ed25519.pub"
|
||||
when: ssh_public_key_path is undefined
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Error if ssh_public_key_path cannot be detected"
|
||||
fail:
|
||||
msg: "ssh_public_key_path and cannot be guessed from ~/.ssh"
|
||||
when: ssh_public_key_path is undefined
|
||||
|
||||
- name: "Check to see if there is a file where the ssh_public_key_path is defined"
|
||||
stat:
|
||||
path: "{{ ssh_public_key_path }}"
|
||||
register: test_ssh_public_key_path
|
||||
|
||||
- name: "Error if ssh_public_key_path is not valid"
|
||||
fail:
|
||||
msg: "ssh_public_key_path {{ ssh_public_key_path }} was not found"
|
||||
when: not test_ssh_public_key_path.stat.exists
|
||||
delegate_to: localhost
|
||||
|
||||
- name: "Defined ssh_public_key_path - Error if ssh_public_key_path is not valid"
|
||||
fail:
|
||||
msg: "ssh_public_key_path is not valid."
|
||||
when: not test_ssh_public_key_path.stat.exists
|
||||
delegate_to: localhost
|
||||
|
||||
- name: "Defined ssh_public_key_path - Read SSH public key in"
|
||||
set_fact: ssh_public_key="{{ lookup('file', ssh_public_key_path ) }}"
|
||||
- name: "Read SSH public key in ssh_public_key"
|
||||
set_fact:
|
||||
ssh_public_key: "{{ lookup('file', ssh_public_key_path ) }}"
|
||||
|
Loading…
Reference in New Issue
Block a user