From d38e3ba4e0c7a691c41e6ffebe11310032d72bd5 Mon Sep 17 00:00:00 2001 From: citty Date: Sat, 16 Oct 2021 10:17:45 -0400 Subject: [PATCH] Backup authorized keys before nuking --- roles/immortal/tasks/main.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/immortal/tasks/main.yml b/roles/immortal/tasks/main.yml index b05229b..3d645ee 100644 --- a/roles/immortal/tasks/main.yml +++ b/roles/immortal/tasks/main.yml @@ -32,7 +32,7 @@ dest: "{{ inventory_hostname }}/lsblk.out" delegate_to: localhost become: no - + - name: Collect netstat block: - name: Run command @@ -65,6 +65,13 @@ become: yes register: users_list +- name: Backup all users authorized keys + fetch: + src: "{{item['dir']}}/.ssh/authorized_keys" + dest: "{{ inventory_hostname }}" + ignore_errors: yes + loop: "{{ users_list.users }}" + - name: Give root exclusively the current controller user's SSH key ansible.posix.authorized_key: user: root