ansible.builtin.hcloud_ssh_key (v2.9.25) — module

Create and manage ssh keys on the Hetzner Cloud.

| "added in version" 2.8 of ansible.builtin"

Authors: Lukas Kaemmerling (@LKaemmerling)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.25

Description

Create, update and manage ssh keys on the Hetzner Cloud.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a basic ssh_key
  hcloud_ssh_key:
    name: my-ssh_key
    public_key: "ssh-rsa AAAjjk76kgf...Xt"
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a ssh_key with labels
  hcloud_ssh_key:
    name: my-ssh_key
    public_key: "ssh-rsa AAAjjk76kgf...Xt"
    labels:
        key: value
        mylabel: 123
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure the ssh_key is absent (remove if needed)
  hcloud_ssh_key:
    name: my-ssh_key
    state: absent

Inputs

    
id:
    description:
    - The ID of the Hetzner Cloud ssh_key to manage.
    - Only required if no ssh_key I(name) is given
    type: int

name:
    description:
    - The Name of the Hetzner Cloud ssh_key to manage.
    - Only required if no ssh_key I(id) is given or a ssh_key does not exists.
    type: str

state:
    choices:
    - absent
    - present
    default: present
    description:
    - State of the ssh_key.
    type: str

labels:
    description:
    - User-defined labels (key-value pairs)
    type: dict

endpoint:
    default: https://api.hetzner.cloud/v1
    description:
    - This is the API Endpoint for the Hetzner Cloud.
    type: str

api_token:
    description:
    - This is the API Token for the Hetzner Cloud.
    required: true
    type: str

public_key:
    description:
    - The Public Key to add.
    - Required if ssh_key does not exists.
    type: str

fingerprint:
    description:
    - The Fingerprint of the Hetzner Cloud ssh_key to manage.
    - Only required if no ssh_key I(id) or I(name) is given.
    type: str

Outputs

hcloud_ssh_key:
  contains:
    fingerprint:
      description: Fingerprint of the ssh_key
      returned: Always
      sample: b7:2f:30:a0:2f:6c:58:6c:21:04:58:61:ba:06:3b:2f
      type: str
    id:
      description: ID of the ssh_key
      returned: Always
      sample: 12345
      type: int
    labels:
      description: User-defined labels (key-value pairs)
      returned: Always
      sample:
        key: value
        mylabel: 123
      type: dict
    name:
      description: Name of the ssh_key
      returned: Always
      sample: my-ssh-key
      type: str
    public_key:
      description: Public key of the ssh_key
      returned: Always
      sample: ssh-rsa AAAjjk76kgf...Xt
      type: str
  description: The ssh_key instance
  returned: Always
  type: complex

See also