Files
@ 6989f0e5db57
Branch filter:
Location: ChaosStuff/cnc-dashboard/roles/initial/tasks/ssh_host.yml - annotation
6989f0e5db57
1.4 KiB
text/x-yaml
Remove unused test task file
c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac c3309581c2ac | # This task list copies over the right SSH host keys
# https://linuxdigest.com/howto/ansible-copy-multiple-files/
# https://stackoverflow.com/questions/53102214/ansible-how-can-i-copy-files-to-hosts-depending-on-group-membership
# https://stackoverflow.com/questions/70378717/ansible-how-to-delete-files-starting-with-a-specific-name
---
- name: Setup ssh keys as root
become: yes
become_method: su
become_user: "root"
vars:
ansible_become_pass: root
block:
- name: List existing host keys
ansible.builtin.find:
paths: /etc/ssh/
patterns: "^ssh_host_.+$"
use_regex: true
register: ssh_host_keys
- name: Delete existing host keys
ansible.builtin.file:
state: absent
path: "{{ item }}"
loop: "{{ ssh_host_keys.files|map(attribute='path')|list }}"
- name: Copy SSH host keys
ansible.builtin.copy:
src: "{{ inventory_hostname }}/"
dest: /etc/ssh
owner: root
group: root
mode: '600'
- name: List public host keys
ansible.builtin.find:
paths: /etc/ssh/
patterns: "^ssh_host_.+_pub$"
use_regex: true
register: ssh_host_keys_pub
- name: change visibility of host public keys
ansible.builtin.file:
path: "{{ item }}"
mode: '644'
loop: "{{ ssh_host_keys_pub.files|map(attribute='path')|list }}"
|