Update create_user_ssh/check_authorizzed_key.yml
This commit is contained in:
parent
8678290e6b
commit
e7fe212fba
|
@ -18,15 +18,16 @@
|
||||||
debug:
|
debug:
|
||||||
msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}"
|
msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}"
|
||||||
|
|
||||||
- name: Add authorized key
|
- name: Add authorized key if it does not exist
|
||||||
authorized_key:
|
block:
|
||||||
user: root # Replace with the remote user's name
|
- name: Add authorized key
|
||||||
state: present
|
authorized_key:
|
||||||
key: "{{ key_to_add }}"
|
user: root # Replace with the remote user's name
|
||||||
|
state: present
|
||||||
|
key: "{{ key_to_add }}"
|
||||||
rescue:
|
rescue:
|
||||||
- name: Handle error when key already exists
|
- name: Handle error when key already exists
|
||||||
debug:
|
debug:
|
||||||
msg: "The authorized key already exists. Skipping addition."
|
msg: "The authorized key already exists. Skipping addition."
|
||||||
|
|
||||||
when: not authorized_key_exists | default(false)
|
when: not authorized_key_exists | default(false)
|
||||||
|
|
Loading…
Reference in New Issue