esp.terraform.tfe_run_info (0.1.0) — module

List Runs in a Workspace

| "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

Lists Runs in a Workspace.

A run performs a plan and apply, using a configuration version and the workspace’s current variables.

A run may be referred either by its id or a custom message associated with it.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Retrieve details on all runs in the workspace
  esp.terraform.tfe_run_info:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    workspace: bar
    run:
      - '*'
    validate_certs: no
  register: _result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Retrieve details on given runs, include additional information about plan, apply and the commit information used in the run
- name: Retrieve details on given runs (supplied by IDs or custom message)
  esp.terraform.tfe_run_info:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    workspace: bar
    run:
      - run-EXKqPDacyxFmsDSG
      - Custom message
    include:
      - plan
      - apply
      - configuration_version.ingress_attributes      
    validate_certs: no
  register: _result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Retrieve details on given runs supplied by custom message with filters
  esp.terraform.tfe_run_info:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    workspace: bar
    run:
      - Custom message
    filter:
      "ingress-attributes":
        "sender-username": 
          - "asmith"
      "configuration-versions":
        "source": 
          - "bitbucket"     
    validate_certs: no
  register: _result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Retrieve details on all runs in the workspace matching the supplied filters (e.g. commit hash)
  esp.terraform.tfe_run_info:
    url: 'https://terraform.example.com'
    token: '{{ token }}'
    organization: foo
    workspace: bar
    run:
      - '*'
    filter:
      "ingress-attributes":
        "commit-sha": 
          - "42e4f31168aa82089aa8ee47c3f9ef74ae85f2e0"
    validate_certs: no
  register: _result

Inputs

    
run:
    default:
    - '*'
    description:
    - List of runs to retrieve details for.
    - This can be '*' which means all runs.
    - One may refer to a run either by its ID or a custom message associated with it.
    required: false
    type: list

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

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

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

include:
    description:
    - Return additional information about nested resources.
    - This can be any of plan, apply, created_by, cost_estimate, configuration_version,
      configuration_version.ingress_attributes.
    elements: str
    required: false
    type: list

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

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.
    required: true
    type: str

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 runs.
      elements: dict
      returned: success
      sample:
      - attributes:
          actions:
            is-cancelable: false
            is-confirmable: false
            is-discardable: false
            is-force-cancelable: false
          canceled-at: null
          created-at: '2021-06-07T07:07:53.003000+00:00'
          has-changes: true
          is-destroy: false
          message: Trigger Terraforom run
          permissions:
            can-apply: true
            can-cancel: true
            can-comment: true
            can-discard: true
            can-force-cancel: true
            can-force-execute: true
            can-override-policy-check: true
          plan-only: false
          source: tfe-configuration-version
          status: applied
          status-timestamps:
            applied-at: '2021-06-07T07:08:39+00:00'
            apply-queued-at: '2021-06-07T07:08:27+00:00'
            applying-at: '2021-06-07T07:08:28+00:00'
            confirmed-at: '2021-06-07T07:08:27+00:00'
            plan-queueable-at: '2021-06-07T07:07:53+00:00'
            plan-queued-at: '2021-06-07T07:07:53+00:00'
            planned-at: '2021-06-07T07:08:27+00:00'
            planning-at: '2021-06-07T07:07:54+00:00'
          target-addrs: null
          trigger-reason: disabled
        id: run-EXKqPDacyxFmsDSG
        links:
          self: /api/v2/runs/run-EXKqPDacyxFmsDSG
        relationships:
          apply:
            data:
              id: apply-bx588DVKD5qiE6Hv
              type: applies
            links:
              related: /api/v2/runs/run-EXKqPDacyxFmsDSG/apply
          configuration-version:
            data:
              id: cv-CnoEnhBDeZaNKN2f
              type: configuration-versions
            links:
              related: /api/v2/runs/run-EXKqPDacyxFmsDSG/configuration-version
          plan:
            data:
              id: plan-E8CDDebTtUSeJPJu
              type: plans
            links:
              related: /api/v2/runs/run-EXKqPDacyxFmsDSG/plan
          workspace:
            data:
              id: ws-xt1dqgiDPEZpJazo
              type: workspaces
        type: runs
      type: list
    included:
      description: Additional information about nested resources.
      elements: dict
      returned: success
      type: list
  description: Details on runs.
  returned: success
  type: dict
organization:
  description: Organization name or external-id.
  returned: always
  sample: foo
  type: str
workspace:
  description: The Workspace name or ID.
  returned: always
  sample: bar
  type: str