Update create_user_ssh/check_authorizzed_key.yml
This commit is contained in:
parent
ca113a58a4
commit
2512bec4aa
|
@ -3,12 +3,9 @@
|
||||||
hosts: "{{ host }}"
|
hosts: "{{ host }}"
|
||||||
gather_facts: yes
|
gather_facts: yes
|
||||||
|
|
||||||
vars:
|
|
||||||
public_key_to_add: "{ key_to_add}" # Replace with the public key you want to add
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Read authorized_keys file
|
- 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
|
register: authorized_key_output
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
@ -24,5 +21,5 @@
|
||||||
authorized_key:
|
authorized_key:
|
||||||
user: root # Replace with the remote user's name
|
user: root # Replace with the remote user's name
|
||||||
state: present
|
state: present
|
||||||
key: "{{ public_key_to_add }}"
|
key: "{{ key_to_add }}"
|
||||||
when: not authorized_key_exists | default(false)
|
when: not authorized_key_exists | default(false)
|
||||||
|
|
Loading…
Reference in New Issue