diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index f950608..3bd019b 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -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 \ No newline at end of file + + rescue: + - name: Handle error when key already exists + debug: + msg: "The authorized key already exists. Skipping addition." + + when: not authorized_key_exists | default(false) \ No newline at end of file