๐ Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
- block:
|
|
|
|
- name: ensure ansible key directory exists
|
|
|
|
file:
|
|
|
|
path: "{{ (ansible_dir, ansible_key_dir) | path_join }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0400
|
|
|
|
|
|
|
|
|
|
|
|
- name: ensure ssh key for this host exists
|
|
|
|
community.crypto.openssh_keypair:
|
|
|
|
path: "{{ (ansible_dir, ansible_key_dir, inventory_hostname) | path_join }}"
|
|
|
|
comment: "{{ inventory_hostname }} ssh key for ansible management"
|
|
|
|
mode: 0400
|
|
|
|
regenerate: full_idempotence
|
|
|
|
type: ed25519
|
|
|
|
register: host_ssh_key
|
|
|
|
|
|
|
|
|
|
|
|
- name: fail if public key is missing
|
|
|
|
fail:
|
|
|
|
msg: public key is missing
|
|
|
|
when: host_ssh_key.public_key is not defined
|
|
|
|
|
|
|
|
delegate_to: localhost
|