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.

register_target

string terraform

The path within the result to register the outputs of this terraform run under.

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
  register_target:
    doc:
      short_help: The path within the result to register the outputs of this terraform
        run under.
    type: string
    required: false
    default: terraform

frecklets:
- frecklet:
    name: terraform
    type: ansible-module
    desc:
      short: 'apply terraform configuration from: {{:: path ::}}'
    register:
      target: '{{:: register_target ::}}'
      value: '{{ __result__.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')
  --register-target REGISTER_TARGET
                                  The path within the result to register the
                                  outputs of this terraform run under.
  --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.
         register_target: The path within the result to register the outputs of this terraform run under.
         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
    register_target: 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", "register_target", "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.
         register_target: The path within the result to register the outputs of this terraform run under.
         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, register_target="terraform", state_file=None, targets=None, variables=None):

        super(TerraformConfigApplied, self).__init__(var_names=["binary_path", "force_init", "path", "register_target", "state_file", "targets", "variables"])
        self._binary_path = binary_path
        self._force_init = force_init
        self._path = path
        self._register_target = register_target
        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 register_target(self):
        return self._register_target

    @register_target.setter
    def register_target(self, register_target):
        self._register_target = register_target

    @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