packet_sshkey - Create/delete an SSH key in Packet host.
New in version 2.3.
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 (on host that executes module)
- python >= 2.6
- packet-python
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
auth_token | no | Packet api token. You can also supply it in env var PACKET_API_TOKEN . | ||
fingerprint | no | Fingerprint of the key which you want to remove. | ||
id | no | UUID of the key which you want to remove. | ||
key | no | Public Key string ({type} {base64 encoded key} {description}). | ||
key_file | no | File with the public key. | ||
label | no | Label for the key. If you keep it empty, it will be read from key string. | ||
state | no | present |
| Indicate desired state of the target. |
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: packet_sshkey: key: "{{ lookup('file', 'my_packet_sshkey.pub') }}" - name: create sshkey from file hosts: localhost tasks: packet_sshkey: label: key from file key_file: ~/ff.pub - name: remove sshkey by id hosts: localhost tasks: packet_sshkey: state: absent id: eef49903-7a09-4ca1-af67-4087c29ab5b6
Return Values
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
changed | True if a sshkey was created or removed. | always | bool | True |
sshkeys | Information about sshkeys that were createe/removed. | always | list | [{'fingerprint': '5c:93:74:7c:ed:07:17:62:28:75:79:23:d6:08:93:46', 'id': '41d61bd8-3342-428b-a09c-e67bdd18a9b7', 'key': 'ssh-dss AAAAB3NzaC1kc3MAAACBAIfNT5S0ncP4BBJBYNhNPxFF9lqVhfPeu6SM1LoCocxqDc1AT3zFRi8hjIf6TLZ2AA4FYbcAWxLMhiBxZRVldT9GdBXile78kAK5z3bKTwq152DCqpxwwbaTIggLFhsU8wrfBsPWnDuAxZ0h7mmrCjoLIE3CNLDA/NmV3iB8xMThAAAAFQCStcesSgR1adPORzBxTr7hug92LwAAAIBOProm3Gk+HWedLyE8IfofLaOeRnbBRHAOL4z0SexKkVOnQ/LGN/uDIIPGGBDYTvXgKZT+jbHeulRJ2jKgfSpGKN4JxFQ8uzVH492jEiiUJtT72Ss1dCV4PmyERVIw+f54itihV3z/t25dWgowhb0int8iC/OY3cGodlmYb3wdcQAAAIBuLbB45djZXzUkOTzzcRDIRfhaxo5WipbtEM2B1fuBt2gyrvksPpH/LK6xTjdIIb0CxPu4OCxwJG0aOz5kJoRnOWIXQGhH7VowrJhsqhIc8gN9ErbO5ea8b1L76MNcAotmBDeTUiPw01IJ8MdDxfmcsCslJKgoRKSmQpCwXQtN2g== tomk@hp2', 'label': 'mynewkey33'}] |
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/packet_sshkey_module.html