updated readme for more complex example

This commit is contained in:
Bertrand Lanson 2023-04-25 19:24:16 +02:00
parent 228d8e50bc
commit ac152bd9a0

View File

@ -87,19 +87,24 @@ Example Playbook
# calling the role inside a playbook with just-in-time provisioning of the ssh public key, and vault storage # calling the role inside a playbook with just-in-time provisioning of the ssh public key, and vault storage
- hosts: servers - hosts: servers
tasks: tasks:
- name: "Dynamic ssh keys generation"
delegate_to: localhost
block:
- name: "Generate a keypair for {{ ansible_hostname }}" - name: "Generate a keypair for {{ ansible_hostname }}"
community.crypto.openssh_keypair: community.crypto.openssh_keypair:
path: "/tmp/id_ed25519_{{ ansible_hostname }}" path: "/tmp/id_ed25519_{{ ansible_hostname }}"
type: ed25519 type: ed25519
owner: root
group: root
delegate_to: localhost delegate_to: localhost
register: _keypair register: _keypair
- name: "Write the private and public key to vault" - name: "Write the private and public key to vault"
community.hashi_vault.vault_write: community.hashi_vault.vault_write:
path: "ansible/ssh_logins/{{ ansible_hostname }}" url: https://vault.domain.tld
path: "ansible/hosts/{{ inventory_hostname }}"
data: data:
data: private_key: "{{ lookup('ansible.builtin.file', '/tmp/id_ed25519_' ~ ansible_hostname ) }}\n"
private_key: "{{ lookup('ansible.builtin.file', '/tmp//tmp/id_ed25519_' ~ ansible_hostname ) }}"
public_key: "{{ _keypair.public_key }}" public_key: "{{ _keypair.public_key }}"
delegate_to: localhost delegate_to: localhost