diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 1de9a06..dc8cafb 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -3,12 +3,9 @@ hosts: "{{ host }}" gather_facts: yes - vars: - public_key_to_add: "{ key_to_add}" # Replace with the public key you want to add - tasks: - name: Read authorized_keys file - shell: cat ~/.ssh/authorized_keys | grep "{{ public_key_to_add }}" + shell: cat ~/.ssh/authorized_keys | grep "{{ key_to_add }}" register: authorized_key_output ignore_errors: yes @@ -24,5 +21,5 @@ authorized_key: user: root # Replace with the remote user's name state: present - key: "{{ public_key_to_add }}" + key: "{{ key_to_add }}" when: not authorized_key_exists | default(false)