new file mode 100644
@@ -0,0 +1,18 @@
+---
+- name: Bring up terraform resources
+ community.general.terraform:
+ project_path: "{{ topdir_path }}/terraform/{{ kdevops_terraform_provider }}"
+ state: present
+ force_init: true
+ tags:
+ - bringup
+
+- name: Destroy terraform resources
+ delegate_to: localhost
+ run_once: true
+ community.general.terraform:
+ project_path: "{{ topdir_path }}/terraform/{{ kdevops_terraform_provider }}"
+ state: absent
+ force_init: true
+ tags:
+ - destroy
new file mode 100644
@@ -0,0 +1,5 @@
+---
+- hosts: all
+ gather_facts: false
+ roles:
+ - role: terraform
deleted file mode 100755
@@ -1,12 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: copyleft-next-0.3.1
-
-set -e
-
-source ${TOPDIR}/.config
-source ${TOPDIR}/scripts/lib.sh
-
-cd terraform/${KDEVOPS_CLOUD_PROVIDER}
-terraform init
-terraform plan
-terraform apply -auto-approve
deleted file mode 100755
@@ -1,10 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: copyleft-next-0.3.1
-
-set -e
-
-source ${TOPDIR}/.config
-source ${TOPDIR}/scripts/lib.sh
-
-cd terraform/${KDEVOPS_CLOUD_PROVIDER}
-terraform destroy -auto-approve
@@ -164,10 +164,18 @@ endif # CONFIG_TERRAFORM_SSH_CONFIG_GENKEY
ANSIBLE_EXTRA_ARGS += $(TERRAFORM_EXTRA_VARS)
bringup_terraform:
- $(Q)$(TOPDIR)/scripts/bringup_terraform.sh
+ $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
+ --connection=local --inventory localhost, \
+ playbooks/terraform.yml --tags bringup \
+ --extra-vars=@./extra_vars.yaml \
+ -e 'ansible_python_interpreter=/usr/bin/python3'
destroy_terraform:
- $(Q)$(TOPDIR)/scripts/destroy_terraform.sh
+ $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
+ --connection=local -i $(KDEVOPS_HOSTFILE) \
+ playbooks/terraform.yml --tags destroy \
+ --extra-vars=@./extra_vars.yaml \
+ -e 'ansible_python_interpreter=/usr/bin/python3'
$(Q)rm -f $(KDEVOPS_PROVISIONED_DEVCONFIG)
$(KDEVOPS_TFVARS): $(KDEVOPS_TFVARS_TEMPLATE) .config