softplayer-ansible/playbooks/other/ssh-key-gen/playbook.yml

21 lines
622 B
YAML

- name: Generate a SSH key
hosts: localhost
connection: local
vars:
output_dir: /tmp/outputs
tasks:
- name: Create the output directory
ansible.builtin.file:
path: "{{ output_dir }}"
state: directory
mode: '0755'
register: workdir
- name: Generate an OpenSSH keypair with the default values (4096 bits, rsa)
community.crypto.openssh_keypair:
path: "{{ output_dir}}/ssh_key"
type: ed25519
- name: Setting host facts using complex arguments
ansible.builtin.set_fact:
pub_key: "{{ lookup('file', '/tmp/outputs/ssh_key.pub') }}"