From eb0c5417d810097da485c4134a207d52f996c777 Mon Sep 17 00:00:00 2001 From: eneller Date: Thu, 24 Jul 2025 22:24:06 +0200 Subject: [PATCH] better ssh playbook --- ssh_addKey.yml | 21 +++++++++++++++++++++ ssh_updateKey.yml | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 ssh_addKey.yml diff --git a/ssh_addKey.yml b/ssh_addKey.yml new file mode 100644 index 0000000..b7fd7df --- /dev/null +++ b/ssh_addKey.yml @@ -0,0 +1,21 @@ +--- +# https://docs.ansible.com/ansible/latest/collections/ansible/posix/authorized_key_module.html#examples +- name: add ssh key + strategy: free # dont wait for other hosts when executing + hosts: all + vars_prompt: + - name: ssh_key_path + prompt: enter the path to the ssh key to add + private: false + tasks: + + - name: Add ssh key + become: true + async: 120 # Maximum execution time + poll: 05 # polling interval in seconds + ansible.posix.authorized_key: + user: "{{ ansible_user_id }}" + exclusive: false + state: present + key: "{{ lookup('file', '{{ ssh_key_path }}') }}" + diff --git a/ssh_updateKey.yml b/ssh_updateKey.yml index a686e8f..d3b4ae3 100644 --- a/ssh_updateKey.yml +++ b/ssh_updateKey.yml @@ -5,7 +5,7 @@ hosts: oracleServer vars_prompt: - name: ssh_key_path - prompt: enter the path to the ssh key to add: + prompt: enter the path to the ssh key to add private: false tasks: