xanmanning.terraform_project

Ansible Role: Terraform Project

This Ansible Role helps create a workflow for managing projects with Hashicorp Terraform.

CI

Requirements

This role works with Ansible version 2.7.0 and above on these Linux distributions:

  • Amazon Linux 2
  • CentOS 8
  • CentOS 7
  • Debian 10
  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS

Disclaimer

If you encounter any issues, please submit a GitHub issue. I work on this role in my free time, so I can't guarantee a quick response.

Role Variables

Variable Description Default Value
terraform_min_version Minimum Terraform version required, e.g., 0.11.0. Use false to skip. false
terraform_max_version Maximum Terraform version allowed, e.g., 0.12.0. Use false to skip. false
terraform_binary_path Path to the Terraform binary. Use false to find Terraform in ${PATH}. false
terraform_exec_projects List of Terraform projects to run. See example below. []
terraform_destroy_all If set to true, will destroy all projects in terraform_exec_projects. Be careful! false

Dependencies

This role does not depend on any other roles.

Example Playbook

This role sets up a workflow in Ansible to support the Terraform process of "plan, then apply". It also checks that the required Terraform version is being used. (For example, if you have a project that is using a pre 0.12 version of Terraform).

---

- hosts: control_hosts
  become: true
  vars:
    terraform_min_version: 0.11.0
    terraform_max_version: 0.12.0
    terraform_exec_projects:
      - project_path: project/       # Required
        state: present               # Optional, default: present
        plan_file: project.tfplan    # Optional, default: project.tfplan
        state_file: project.tfstate  # Optional, default: project.tfstate
        workspace: default           # Optional, workspace to use.
        purge_workspace: false       # Optional, delete workspace when destroying?
        lock: true                   # Optional, lock state file if supported.
        lock_timeout: 300            # Optional, duration to hold the lock if supported.
        force_init: true             # Optional
        backend_config_files:        # Optional, list of files for backend configuration.
          - config.hcl
        backend_config:              # Optional, parameters needed during initialization.
          region: "eu-west-1"
          bucket: "some-bucket"
          key: "random.tfstate"
        targets:                     # Optional, specific resources to plan/apply.
          some_target
        variables_file: dev.tfvars   # Optional, path to the variables file.
        variables:                   # Optional, additional variable values.
          vm_size: t3.large
  roles:
    - role: xanmanning.terraform_project

License

BSD 3-clause

Author Information

Xan Manning

Informazioni sul progetto

Ansible Role that wraps around and builds a workflow around Terraform projects.

Installa
ansible-galaxy install xanmanning.terraform_project
Licenza
bsd-3-clause
Download
207
Proprietario
Deep in the lab...