Update create_user_ssh/check_authorizzed_key.yml

This commit is contained in:
David Lopez 2023-07-27 09:09:05 +00:00
parent b72d005b96
commit 8678290e6b
1 changed files with 7 additions and 1 deletions

View File

@ -23,4 +23,10 @@
user: root # Replace with the remote user's name
state: present
key: "{{ key_to_add }}"
when: authorized_key_exists | default(false) | not
rescue:
- name: Handle error when key already exists
debug:
msg: "The authorized key already exists. Skipping addition."
when: not authorized_key_exists | default(false)