updated readme for more complex example
This commit is contained in:
parent
228d8e50bc
commit
ac152bd9a0
11
README.md
11
README.md
@ -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
|
||||
- hosts: servers
|
||||
tasks:
|
||||
- name: "Dynamic ssh keys generation"
|
||||
delegate_to: localhost
|
||||
block:
|
||||
- name: "Generate a keypair for {{ ansible_hostname }}"
|
||||
community.crypto.openssh_keypair:
|
||||
path: "/tmp/id_ed25519_{{ ansible_hostname }}"
|
||||
type: ed25519
|
||||
owner: root
|
||||
group: root
|
||||
delegate_to: localhost
|
||||
register: _keypair
|
||||
|
||||
- name: "Write the private and public key to vault"
|
||||
community.hashi_vault.vault_write:
|
||||
path: "ansible/ssh_logins/{{ ansible_hostname }}"
|
||||
url: https://vault.domain.tld
|
||||
path: "ansible/hosts/{{ inventory_hostname }}"
|
||||
data:
|
||||
data:
|
||||
private_key: "{{ lookup('ansible.builtin.file', '/tmp//tmp/id_ed25519_' ~ ansible_hostname ) }}"
|
||||
private_key: "{{ lookup('ansible.builtin.file', '/tmp/id_ed25519_' ~ ansible_hostname ) }}\n"
|
||||
public_key: "{{ _keypair.public_key }}"
|
||||
delegate_to: localhost
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user