community.general.packet_sshkey module – Create/delete an SSH key in Packet host
Note
This module is part of the community.general collection (version 10.7.5).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.packet_sshkey.
Synopsis
- Create/delete an SSH key in Packet host. 
- API is documented at https://www.packet.net/help/api/#page:ssh-keys,header:ssh-keys-ssh-keys-post. 
Requirements
The below requirements are needed on the host that executes this module.
- packet-python 
Parameters
| Parameter | Comments | 
|---|---|
| Packet API token. You can also supply it in environment variable  | |
| Fingerprint of the key which you want to remove. | |
| UUID of the key which you want to remove. | |
| Public Key string ( | |
| File with the public key. | |
| Label for the key. If you keep it empty, it is read from key string. | |
| Indicate desired state of the target. Choices: 
 | 
Attributes
| Attribute | Support | Description | 
|---|---|---|
| Support: none | Can run in  | |
| Support: none | Will return details on what has changed (or possibly needs changing in  | 
Examples
# All the examples assume that you have your Packet API token in env var PACKET_API_TOKEN.
# You can also pass the api token in module param auth_token.
- name: Create sshkey from string
  hosts: localhost
  tasks:
    community.general.packet_sshkey:
      key: "{{ lookup('file', 'my_packet_sshkey.pub') }}"
- name: Create sshkey from file
  hosts: localhost
  tasks:
    community.general.packet_sshkey:
      label: key from file
      key_file: ~/ff.pub
- name: Remove sshkey by id
  hosts: localhost
  tasks:
    community.general.packet_sshkey:
      state: absent
      id: eef49903-7a09-4ca1-af67-4087c29ab5b6
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| Information about sshkeys that were created/removed. Returned: always Sample:  | 
