Skip to content

TF generator Ansible Role - TF manifests generation and management

License

Notifications You must be signed in to change notification settings

mmul-it/tfs_generator

Repository files navigation

TFs generator Ansible Role

This role can be used to install tf tool binary and deploy tf manifest files (.tf) starting from an Ansible inventory, to create a fully atomated and idempotent Infrastructure as Code scenario.

Lint and test the project Ansible Galaxy

Role Variables

All the useful variables are commented into the defaults file, the main ones are these:

---

# Install tf cmd binary
tf_binary_install: true
tf_binary_version: '0.14.2'
tf_binary_platform: 'linux_amd64'
tf_binary_url: "https://releases.hashicorp.com/terraform/{{ tf_binary_version }}/\
                terraform_{{ tf_binary_version }}_{{ tf_binary_platform }}.zip"

# Name of the command used to generate tf files
tf_cmd: 'terraform'

# Where to deploy tf resource files
tf_config_dir: 'tfs'

# Delete existing resources before deploying new ones
tf_purge: false

To start working with this role you'll need to choose which provider will be used to generate tf manifests, currently libvirt (default) and azure are the two supporterd providers.

# Which environment we're going to deploy
tf_cloud_provider: 'libvirt'

To get specific configuration options look at the Libvirt or Azure page:

Libvirt Azure

Example playbook

To test this role and generate a set of tf manifests, just use the tests/tfs_generator.yml playbook passing the test inventory with -i tests/inventory:

> ansible-playbook -i tests/inventory tests/tfs_generator.yml

PLAY [Create tf manifests using tfs_generator Ansible role] ******************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************
ok: [localhost]

...
...

PLAY RECAP ************************************************************************************************************************************************
localhost                  : ok=15   changed=7    unreachable=0    failed=0    skipped=2    rescued=0    ignored=0

This will generate a tests/tf directory containing all the generated manifests.

To learn how to use this with the tf tool to automate environment generation check the Libvirt page.

License

MIT

Author Information

Raoul Scarazzini (rascasoft)

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages