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

Improve key distribution

parent 06ce3e81
Branches
No related tags found
No related merge requests found
---
# file: roles/commonkeys/tasks/main.yml
- include: distribute_tunnel_keys.yml
- include: reset.yml
with_items: '{{ groups.all }}'
when: item != "localhost" and inventory_hostname != "localhost"
- include: distribute_keys.yml
- include: tunnel_keys.yml
- include: user_keys.yml
with_flattened:
- '{{ admins }}'
- '{{ jailusers }}'
......
---
# file: roles/commonauth/tasks/reset.yml
- name: "Remove previous hostname from known_hosts"
become: no
known_hosts:
name="{{ item }}"
state="absent"
- name: "Remove previous ip from known_hosts"
become: no
known_hosts:
name="{{ hostvars[item]['static_ipv4']|default(hostvars[item]['ansible_default_ipv4']['address']) }}"
state="absent"
- name: "Include all hosts into /etc/hosts"
lineinfile:
dest=/etc/hosts
regexp="^{{ hostvars[item]['static_ipv4']|default(hostvars[item]['ansible_default_ipv4']['address']) }} "
line="{{ hostvars[item]['static_ipv4']|default(hostvars[item]['ansible_default_ipv4']['address']) }} {{ item }}"
---
# file: roles/commonauth/tasks/distribute_tunnel_keys.yml
# file: roles/commonauth/tasks/tunnel_keys.yml
- name: "Include all hosts into /etc/hosts"
lineinfile:
dest=/etc/hosts
regexp="^{{ hostvars[item]['static_ipv4']|default(hostvars[item]['ansible_default_ipv4']['address']) }} "
line="{{ hostvars[item]['static_ipv4']|default(hostvars[item]['ansible_default_ipv4']['address']) }} {{ item }}"
with_items: '{{ groups.all }}'
when: item != "localhost" and inventory_hostname != "localhost"
- name: "Keys | Read public key of tunnel user"
- name: "Read public key of tunnel user"
shell: cat /home/{{ tunnel_user_name }}/.ssh/id_rsa.pub
register: pubkey
......
# ================= Rebuild keys auth for all admins ===========================
---
# file: roles/commonauth/tasks/distribute_keys.yml
# file: roles/commonauth/tasks/user_keys.yml
- name: "Keys | Remove the fresh auth file in case it does already exist"
file:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment