Skip to content

Instantly share code, notes, and snippets.

@mkrizek
Created July 15, 2022 09:47
Show Gist options
  • Save mkrizek/974ac736ea78b9bb4cddb62c376113ef to your computer and use it in GitHub Desktop.
Save mkrizek/974ac736ea78b9bb4cddb62c376113ef to your computer and use it in GitHub Desktop.
terraform {
required_providers {
{{ tf_provider['name'] }} = {
source = "{{ tf_provider['source'] }}"
version = "{{ tf_provider['version'] }}"
}
}
}
- hosts: localhost
gather_facts: false
tasks:
- template:
src: test.j2
dest: out
vars:
tf_provider:
name: "null"
source: "hashicorp/null"
version: ">=2.0.0, < 3.0.0"
@felixfontein
Copy link

Or simply use this template:

{{ a.name }}

and this playbook:

- hosts: localhost
  gather_facts: false
  tasks:
    - template:
        src: test.j2
        dest: out
      vars:
        a: "{{ b }}"
        b:
          name: foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment