1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

docs: add example with user-data and custom host ssh keys

This commit is contained in:
jo 2025-12-12 12:46:44 +01:00
parent 55cc1fa3a9
commit 7ad1b31570
No known key found for this signature in database
GPG key ID: B2FEC9B22722B984

View file

@ -0,0 +1,40 @@
---
- name: Demonstrate the usage of 'user_data'
hosts: localhost
connection: local
tasks:
- name: Create host ssh keys
community.crypto.openssh_keypair:
path: "ssh_host_{{ item }}_key"
type: "{{ item }}"
loop: [ed25519, ecdsa, rsa]
register: host_ssh_keys
- name: Print host ssh keys fingerprint
ansible.builtin.debug:
msg: "{{ item.fingerprint }}"
loop: "{{ host_ssh_keys.results }}"
loop_control:
label: "{{ item.type }}"
- name: Create server
hetzner.hcloud.server:
name: my-server
server_type: cx23
image: debian-13
user_data: |
#cloud-config
ssh_deletekeys: true
ssh_keys:
ed25519_private: |
{{ lookup('file', 'ssh_host_ed25519_key') | indent(4) }}
ed25519_public: "{{ lookup('file', 'ssh_host_ed25519_key.pub') }}"
ecdsa_private: |
{{ lookup('file', 'ssh_host_ecdsa_key') | indent(4) }}
ecdsa_public: "{{ lookup('file', 'ssh_host_ecdsa_key.pub') }}"
rsa_private: |
{{ lookup('file', 'ssh_host_rsa_key') | indent(4) }}
rsa_public: "{{ lookup('file', 'ssh_host_rsa_key.pub') }}"