esp.terraform.tfe_workspace_var (0.1.0) — module

Create, update, and delete workspace variables

| "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, updates or deletes workspace variables.

A variable may be referred either by its ID or by its name (key).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a Variable
  esp.terraform.tfe_workspace_var:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    workspace: bar
    attributes:
      "key": some_key
      "value": some_value
      "description": some description
      "category": terraform
      "hcl": false
      "sensitive": false
    state: present
    validate_certs: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Edit a Variable
  esp.terraform.tfe_workspace_var:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    workspace: bar
    variable: var-sCmHmHGSTYCp38sY
    attributes:      
      "value": new_some_value
      "description": updated variable
      "sensitive": true
    state: present
    validate_certs: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a Variable
  esp.terraform.tfe_workspace_var:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    workspace: bar
    variable: AWS_SECRET_ACCESS_KEY
    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 variable 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

variable:
    description:
    - Variable to edit or remove.
    - The variable may be referred either by its id or its name (key).
    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

workspace:
    description:
    - The workspace name or ID to manage variables for.
    required: true
    type: str

attributes:
    description:
    - Definition of the attributes for the variable.
    - Required when C(state=present).
    required: false
    suboptions:
      category:
        description:
        - Whether this is a Terraform or environment variable.
        - Valid values are C(terraform) or C(env).
        required: true
        type: str
      description:
        description:
        - The description of the variable.
        required: true
        type: str
      hcl:
        description:
        - Whether to evaluate the value of the variable as a string of HCL code. Has no
          effect for environment variables.
        required: false
        type: bool
      key:
        description:
        - Name of the variable.
        required: true
        type: str
      sensitive:
        description:
        - Whether the value is sensitive. If C(true) then the variable is written once
          and not visible thereafter.
        required: false
        type: bool
      value:
        description:
        - The value of the variable.
        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 variable.
      returned: success
      sample:
        attributes:
          category: terraform
          created-at: '2021-05-17T14:19:46.941000+00:00'
          description: some description
          hcl: false
          key: some_key
          sensitive: false
          value: some_value
        id: var-PLmSNFWk1y5X7NqR
        links:
          self: /api/v2/workspaces/ws-NX8cHwQMGHQohG79/vars/var-PLmSNFWk1y5X7NqR
        relationships:
          configurable:
            data:
              id: ws-NX8cHwQMGHQohG79
              type: workspaces
            links:
              related: /api/v2/organizations/foo/workspaces/bar
        type: vars
      type: dict
  description: Details on the variable.
  returned: success
  type: dict