better ssh playbook

This commit is contained in:
eneller
2025-07-24 22:24:06 +02:00
parent 859119856e
commit eb0c5417d8
2 changed files with 22 additions and 1 deletions

21
ssh_addKey.yml Normal file
View File

@@ -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 }}') }}"

View File

@@ -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: