This commit is contained in:
parent
555f8836c1
commit
544027debb
|
@ -1,7 +1,10 @@
|
||||||
---
|
---
|
||||||
- name: Check and Add Authorized Key
|
- hosts: "{{ host }}"
|
||||||
hosts: "{{ hosts_servers }}"
|
gather_facts: no
|
||||||
gather_facts: yes
|
vars:
|
||||||
|
key_to_add: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDXzZ9SOKE/2uuXEeiFmOyYG0qR0thjjfxylJxURFoXE2SnUqJI3ZPac2f3KK4fScHKpAnFL4OARHi8cLFI3Uwcn40GEvRBArmUrNnPdCIWk2YH8GYNNfbQkWfcXxOAwHsM7XMgiZ7PAp0nG4u2aO+1GWOTkczBaVZ53mIlSUXnfo+EYUMwheixBydHDSYmOU7JHEw5YggXt0wds0fbzVk1bT++EAIS705m/14AcpGpeJgWpviCLzkfJNe7sbyuQdTVuP2pP7KN/NgmQQPZdniKbYIf+wz3TfkHRTNtg+N86C48aWfTfRncHgFQI4tQnCFWxrbydRJL0lpg2sRqYXrXNGLRzofLJRtx5yP4F2G0R9XBBnA/WknqjiLw4DKC73tAkqSPTciIHqBsjNo0wI15fu63TGQz8hKDecqJOso5tTpSlofTdRtvgCaLLMogS4uUmj4QZYpQ+9SRBeS33CLD4DUUN8Oc7V5f3EK4/GZKfuBHAne1tfDZN0A5UKieyfE= awx@awx.verdnatura.es
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Read authorized_keys file
|
- name: Read authorized_keys file
|
||||||
|
@ -17,9 +20,15 @@
|
||||||
debug:
|
debug:
|
||||||
msg: "Authorized key exists: {{ authorized_key_exists }}"
|
msg: "Authorized key exists: {{ authorized_key_exists }}"
|
||||||
|
|
||||||
- name: Add authorized key
|
- name: Create user with hash
|
||||||
authorized_key:
|
user:
|
||||||
user: root # Replace with the remote user's name
|
name: awx
|
||||||
state: present
|
state: present
|
||||||
|
shell: /bin/bash
|
||||||
|
- name: Add ssh pub keys AWX
|
||||||
|
authorized_key:
|
||||||
|
user: awx
|
||||||
key: "{{ key_to_add }}"
|
key: "{{ key_to_add }}"
|
||||||
when: not authorized_key_exists | default(false)
|
state: present
|
||||||
|
manage_dir: yes
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue