esp.terraform.tfe_ssh_key (0.1.0) — module

Create, update, and delete SSH keys

| "added in version" 0.1.0 of esp.terraform"

Authors: Krzysztof Lewandowski (@klewan)

Install collection

Install with ansible-galaxy collection install esp.terraform:==0.1.0


Add to requirements.yml

  collections:
    - name: esp.terraform
      version: 0.1.0

Description

Creates, edits or deletes Terraform SSH keys.

SSH keys can be used in two places, i.e. they can be assigned to VCS provider integrations,

they can be assigned to workspaces and used when Terraform needs to clone modules from a Git server.

An SSH key can be referred either by its ID or by its name.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create an SSH Key
  esp.terraform.tfe_ssh_key:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo    
    attributes:
      "name": my-ssh-key
      "value": "{{ lookup('file', 'files/private.key') }}"
    state: present
    validate_certs: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update an SSH Key
  esp.terraform.tfe_ssh_key:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    ssh_key: my-ssh-key 
    attributes:
      "value": "{{ lookup('file', 'files/new.private.key') }}"
    state: present
    validate_certs: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete an SSH Key (supplied by its name)
  esp.terraform.tfe_ssh_key:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    ssh_key: my-ssh-key
    state: absent
    validate_certs: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete an SSH Key (supplied by its ID)
  esp.terraform.tfe_ssh_key:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    ssh_key: sshkey-1nXFmNCq38FDyUqo
    state: absent
    validate_certs: no    

Inputs

    
url:
    description:
    - Terraform Enterprise URL.
    required: false
    type: str

sleep:
    default: 5
    description:
    - Number of seconds to sleep between API retries.
    type: int

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Whether the SSH key should exist or not.
    required: true
    type: str

token:
    description:
    - All requests to Terraform Enterprise must be authenticated with a bearer token.
    - There are three kinds of token available, i.e. user tokens, team tokens and organization
      tokens.
    - See L(Authentication,https://www.terraform.io/docs/cloud/api/index.html#authentication).
    required: true
    type: str

retries:
    default: 3
    description:
    - Number of retries to call Terraform API URL before failure.
    type: int

ssh_key:
    description:
    - SSH key to edit or remove.
    - SSH key may be referred either by its id or its name.
    required: false
    type: str

use_proxy:
    default: true
    description:
    - If C(no), it will not use a proxy, even if one is defined in an environment variable
      on the target hosts.
    type: bool

attributes:
    description:
    - Definition of the attributes for the SSH key.
    - Required when C(state=present).
    required: false
    suboptions:
      name:
        description:
        - A name to identify the SSH key.
        required: true
        type: str
      value:
        description:
        - The text of the SSH private key
        required: false
        type: str
    type: dict

organization:
    description:
    - Organization name.
    required: true
    type: str

validate_certs:
    default: true
    description:
    - If C(no), SSL certificates will not be validated.
    - This should only set to C(no) used on personally controlled sites using self-signed
      certificates.
    type: bool

Outputs

json:
  contains:
    data:
      description: Details on the SSH key.
      returned: success
      sample:
        attributes:
          name: my-ssh-key
        id: sshkey-ZUVVrX3Vov4qyWB4
        links:
          self: /api/v2/ssh-keys/sshkey-ZUVVrX3Vov4qyWB4
        type: ssh-keys
      type: dict
  description: Details on the SSH key.
  returned: success
  type: dict