feat: Create skeleton for terraform provisioning role

The terraform module does not expect its file contents (project_path) in
the 'files/' folder like the core roles, instead looking for it relative
to the _invocation_ pwd.
So, for now it just resides in the root level of the repository and may
be moved from there to wherever it is more pertinent.

Additionally, we check for the existence of the OpenTofu binary (tofu),
and prefer that if it exists. Otherwise we fall back to the Terraform
binary.
This commit is contained in:
Marty Oehme 2025-11-20 21:27:06 +01:00
parent 2957b58491
commit 40b687a3f3
Signed by: Marty
GPG key ID: 4E535BC19C61886E
3 changed files with 38 additions and 1 deletions

View file

@ -0,0 +1,26 @@
---
# role currently only works with opentofu
# Either manually extend to both or just leave out test?
- name: Check if tofu is installed
vars:
terraform_bin: tofu
ansible.builtin.command:
argv:
- which
- "{{ terraform_bin|quote }}"
check_mode: false # run even in check mode
tags: debug
register: tofu_installed
failed_when: false
changed_when: false
- name: Run terraform
community.general.terraform:
binary_path: "{{ (tofu_installed.rc in [ 0 ]) | ternary('tofu', 'terraform') }}"
project_path: "tofu/"
state: present
register: output
- name: Debug output
debug:
var: output

View file

@ -5,7 +5,6 @@
gather_facts: False gather_facts: False
become: true become: true
tags: tags:
- system
- bootstrap - bootstrap
tasks: tasks:
- name: check for python - name: check for python
@ -50,6 +49,13 @@
# name: incus-install # name: incus-install
# tags: incus # tags: incus
- name: Raise infrastructure
hosts: localhost
tags: infrastructure
tasks:
- ansible.builtin.import_role:
name: infrastructure
# ansible-galaxy install geerlingguy.docker # ansible-galaxy install geerlingguy.docker
- name: Install docker - name: Install docker
hosts: instance_system hosts: instance_system

5
tofu/main.tf Normal file
View file

@ -0,0 +1,5 @@
output "my_debug_output" {
description = "just debuggin"
value = 42
}