terraform-config-applied

Example:

# Apply existing terraform configuration.
- terraform-config-applied:
    path: /home/freckles/projects/terraform/my_project

Description

Apply a terraform configuration using the Ansible 'terraform' module.

Resources

Variables

Name Type Default Description

path

string --

The path to the terraform configuration folder. Required

binary_path

string --

The path of a terraform binary to use, relative to the 'path' unless you supply an absolute path.

force_init

boolean --

To avoid duplicating infra, if a state file can't be found this will force a terraform init. Generally, this should be turned off unless you intend to provision an entirely new Terraform deployment.

state_file

string --

The path to an existing Terraform state file to use when building plan. If this is not specified, the default terraform.tfstate will be used.

targets

list --

A list of specific resources to target in this plan/application. The resources selected here will also auto-include any dependencies.

variables

dict --

A group of key-values to override template variables or those in variables files

Examples

Example 1

Apply existing terraform configuration.

Code
- terraform-config-applied:
    path: /home/freckles/projects/terraform/my_project

Code

doc:
  short_help: Apply a terraform configuration.
  help: |
    Apply a terraform configuration using the Ansible 'terraform' module.
  references:
    Terraform homepage: https://www.terraform.io/
    Ansible terraform module documentation: https://docs.ansible.com/ansible/latest/modules/terraform_module.html
  examples:
  - title: Apply existing terraform configuration.
    vars:
      path: /home/freckles/projects/terraform/my_project

args:
  path:
    doc:
      short_help: The path to the terraform configuration folder.
    type: string
    required: true
    cli:
      param_type: argument
  state_file:
    doc:
      short_help: The path to an existing Terraform state file to use when building
        plan.
      help: |
        The path to an existing Terraform state file to use when building plan. If this is not specified, the default `terraform.tfstate` will be used.
    type: string
    required: false
  force_init:
    doc:
      short_help: To avoid duplicating infra, if a state file can't be found this
        will force a `terraform init` (defaults to 'false')
      help: |
        To avoid duplicating infra, if a state file can't be found this will force a `terraform init`. Generally, this should be turned off unless you intend to provision an entirely new Terraform deployment.
    type: boolean
    required: false
    cli:
      param_decls:
      - --force-init
  binary_path:
    doc:
      short_help: The path of a terraform binary to use, relative to the 'path' unless
        you supply an absolute path.
    type: string
    required: false
  variables:
    doc:
      short_help: A group of key-values to override template variables or those in
        variables files
    type: dict
    keyschema:
      type: string
    required: false
  targets:
    doc:
      short_help: A list of specific resources to target in this plan/application.
        The resources selected here will also auto-include any dependencies.
    type: list
    schema:
      type: string
    required: false

frecklets:
- frecklet:
    name: terraform
    type: ansible-module
    desc:
      short: 'apply terraform configuration from: {{:: path ::}}'
    register:
      var: terraform
      query: /outputs
  vars:
    project_path: '{{:: path ::}}'
    state: present
    state_file: '{{:: state_file ::}}'
    force_init: '{{:: force_init ::}}'
    binary_path: '{{:: binary_path ::}}'
    variables: '{{:: variables ::}}'
    targets: '{{:: targets ::}}'
frecklecute terraform-config-applied --help

Usage: frecklecute terraform-config-applied [OPTIONS] PATH

  Apply a terraform configuration using the Ansible 'terraform' module.

Options:
  --binary-path BINARY_PATH  The path of a terraform binary to use, relative
                             to the 'path' unless you supply an absolute path.
  --force-init               To avoid duplicating infra, if a state file can't
                             be found this will force a `terraform init`
                             (defaults to 'false')
  --state-file STATE_FILE    The path to an existing Terraform state file to
                             use when building plan.
  --targets TARGETS          A list of specific resources to target in this
                             plan/application. The resources selected here
                             will also auto-include any dependencies.
  --variables VARIABLES      A group of key-values to override template
                             variables or those in variables files
  --help                     Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.terraform_config_applied.TerraformConfigApplied
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class TerraformConfigApplied(AutoPycklet):
    """Apply a terraform configuration using the Ansible 'terraform' module.

       Args:
         binary_path: The path of a terraform binary to use, relative to the 'path' unless you supply an absolute path.
         force_init: To avoid duplicating infra, if a state file can't be found this will force a `terraform init` (defaults to 'false')
         path: The path to the terraform configuration folder.
         state_file: The path to an existing Terraform state file to use when building plan.
         targets: A list of specific resources to target in this plan/application. The resources selected here will also auto-include any dependencies.
         variables: A group of key-values to override template variables or those in variables files

    """

    FRECKLET_ID = "terraform-config-applied"

    binary_path: str = None
    force_init: bool = None
    path: str = None
    state_file: str = None
    targets: List = None
    variables: Dict = None


    def __post_init__(self):
        super(TerraformConfigApplied, self).__init__(var_names=["binary_path", "force_init", "path", "state_file", "targets", "variables"])


frecklet_class = TerraformConfigApplied
# -*- coding: utf-8 -*-


#
# module path: pycklets.terraform_config_applied.TerraformConfigApplied
#


from pyckles import AutoPycklet

class TerraformConfigApplied(AutoPycklet):
    """Apply a terraform configuration using the Ansible 'terraform' module.

       Args:
         binary_path: The path of a terraform binary to use, relative to the 'path' unless you supply an absolute path.
         force_init: To avoid duplicating infra, if a state file can't be found this will force a `terraform init` (defaults to 'false')
         path: The path to the terraform configuration folder.
         state_file: The path to an existing Terraform state file to use when building plan.
         targets: A list of specific resources to target in this plan/application. The resources selected here will also auto-include any dependencies.
         variables: A group of key-values to override template variables or those in variables files

    """

    FRECKLET_ID = "terraform-config-applied"

    def __init__(self, binary_path=None, force_init=None, path=None, state_file=None, targets=None, variables=None):

        super(TerraformConfigApplied, self).__init__(var_names=["binary_path", "force_init", "path", "state_file", "targets", "variables"])
        self._binary_path = binary_path
        self._force_init = force_init
        self._path = path
        self._state_file = state_file
        self._targets = targets
        self._variables = variables

    @property
    def binary_path(self):
        return self._binary_path

    @binary_path.setter
    def binary_path(self, binary_path):
        self._binary_path = binary_path

    @property
    def force_init(self):
        return self._force_init

    @force_init.setter
    def force_init(self, force_init):
        self._force_init = force_init

    @property
    def path(self):
        return self._path

    @path.setter
    def path(self, path):
        self._path = path

    @property
    def state_file(self):
        return self._state_file

    @state_file.setter
    def state_file(self, state_file):
        self._state_file = state_file

    @property
    def targets(self):
        return self._targets

    @targets.setter
    def targets(self, targets):
        self._targets = targets

    @property
    def variables(self):
        return self._variables

    @variables.setter
    def variables(self, variables):
        self._variables = variables



frecklet_class = TerraformConfigApplied