Skip to content
Snippets Groups Projects
Commit e533402c authored by jurgenhaas's avatar jurgenhaas
Browse files

Dstribute pub keys of all admins to all hosts in the same farm

parent 5b59e338
No related branches found
No related tags found
No related merge requests found
---
# file: roles/commonkeys/tasks/tunnel_keys.yml
# file: roles/commonkeys/tasks/admin_keys.yml
- name: "Read public key of tunnel user"
shell: cat /home/{{ tunnel_user_name }}/.ssh/id_rsa.pub
- name: "Read public key of admin user"
shell: cat /home/{{ username }}/.ssh/id_rsa.pub
register: pubkey
- name: "Distribute public key of tunnel user"
- name: "Distribute public key of admin user"
authorized_key:
user='{{ tunnel_user_name }}'
user='{{ username }}'
key="{{ hostvars[item].pubkey.stdout }} {{ item }}"
path='/home/{{ tunnel_user_name }}/.ssh/fresh_auth_keys_tunnel_{{ item }}'
path='/home/{{ username }}/.ssh/fresh_auth_keys_tunnel_{{ item }}'
with_items: '{{ groups.all }}'
when: item != "localhost" and inventory_hostname != "localhost" and hostvars[item].pubkey is defined
......@@ -14,9 +14,11 @@
loop_var: hostname
when: hostname != "localhost" and inventory_hostname != "localhost"
- name: "Tunnel keys"
include: tunnel_keys.yml
when: tunnel_user_name|default('systunnel') in admins
- name: "Admin keys"
include: admin_keys.yml
loop_control:
loop_var: username
with_items: '{{ admins }}'
tags: 'Keys'
- name: "User keys"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment