community.general.cs_sshkeypair (0.1.1) — module

Manages SSH keys on Apache CloudStack based clouds.

Authors: René Moser (@resmo)

stableinterface | supported by community

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

Create, register and remove SSH keys.

If no key was found and no public key was provided and a new SSH private/public key pair will be created and the private key will be returned.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: create a new private / public key pair
  cs_sshkeypair:
    name: linus@example.com
  delegate_to: localhost
  register: key
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    msg: 'Private key is {{ key.private_key }}'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: remove a public key by its name
  cs_sshkeypair:
    name: linus@example.com
    state: absent
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: register your existing local public key
  cs_sshkeypair:
    name: linus@example.com
    public_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
  delegate_to: localhost

Inputs

    
name:
    description:
    - Name of public key.
    required: true
    type: str

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

domain:
    description:
    - Domain the public key is related to.
    type: str

account:
    description:
    - Account the public key is related to.
    type: str

api_key:
    description:
    - API key of the CloudStack API.
    - If not given, the C(CLOUDSTACK_KEY) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

api_url:
    description:
    - URL of the CloudStack API e.g. https://cloud.example.com/client/api.
    - If not given, the C(CLOUDSTACK_ENDPOINT) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

project:
    description:
    - Name of the project the public key to be registered in.
    type: str

api_region:
    default: cloudstack
    description:
    - Name of the ini section in the C(cloustack.ini) file.
    - If not given, the C(CLOUDSTACK_REGION) env variable is considered.
    type: str

api_secret:
    description:
    - Secret key of the CloudStack API.
    - If not set, the C(CLOUDSTACK_SECRET) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

public_key:
    description:
    - String of the public key.
    type: str

api_timeout:
    description:
    - HTTP timeout in seconds.
    - If not given, the C(CLOUDSTACK_TIMEOUT) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    - Fallback value is 10 seconds if not specified.
    type: int

api_http_method:
    choices:
    - get
    - post
    description:
    - HTTP method used to query the API endpoint.
    - If not given, the C(CLOUDSTACK_METHOD) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    - Fallback value is C(get) if not specified.
    type: str

Outputs

fingerprint:
  description: Fingerprint of the SSH public key.
  returned: success
  sample: 86:5e:a3:e8:bd:95:7b:07:7c:c2:5c:f7:ad:8b:09:28
  type: str
id:
  description: UUID of the SSH public key.
  returned: success
  sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
  type: str
name:
  description: Name of the SSH public key.
  returned: success
  sample: linus@example.com
  type: str
private_key:
  description: Private key of generated SSH keypair.
  returned: changed
  sample: '-----BEGIN RSA PRIVATE KEY----- MII...8tO -----END RSA PRIVATE KEY----- '
  type: str