diff --git a/ansible/deploy_tf.yml b/ansible/deploy_tf.yml deleted file mode 100644 index 6385878..0000000 --- a/ansible/deploy_tf.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- name: Deploy a Terraform infrastructure - hosts: localhost - gather_facts: false - tasks: - - - name: Create a VM - cloud.terraform.terraform: - project_path: /home/vez/homelab/terraform/projects/terransible - state: present - register: tf_return - - - name: Refresh inventory - ansible.builtin.meta: refresh_inventory - -- name: Ping - hosts: servers - gather_facts: false - tasks: - - - name: Ping the host group - ansible.builtin.ping: \ No newline at end of file diff --git a/ansible/inventory/terraform.yml b/ansible/inventories/terraform.yml similarity index 100% rename from ansible/inventory/terraform.yml rename to ansible/inventories/terraform.yml diff --git a/ansible/playbooks/deploy_tf.yml b/ansible/playbooks/deploy_tf.yml new file mode 100644 index 0000000..f20596c --- /dev/null +++ b/ansible/playbooks/deploy_tf.yml @@ -0,0 +1,17 @@ +--- +- name: Deploy a Terraform infrastructure + hosts: localhost + gather_facts: false + tasks: + - name: Create a VM with Terraform + ansible.builtin.import_role: + name: terraform_vm + vars: + terraform_vm_project_path: /home/vez/homelab/terraform/projects/terransible + +- name: Ping + hosts: servers + gather_facts: false + tasks: + - name: Ping the host group + ansible.builtin.ping: \ No newline at end of file diff --git a/ansible/roles/terraform_vm/defaults/main.yml b/ansible/roles/terraform_vm/defaults/main.yml new file mode 100644 index 0000000..de3033c --- /dev/null +++ b/ansible/roles/terraform_vm/defaults/main.yml @@ -0,0 +1,2 @@ +--- +terraform_vm_state: present \ No newline at end of file diff --git a/ansible/roles/terraform_vm/tasks/main.yml b/ansible/roles/terraform_vm/tasks/main.yml new file mode 100644 index 0000000..4a9b4f0 --- /dev/null +++ b/ansible/roles/terraform_vm/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- name: Create a VM + cloud.terraform.terraform: + project_path: "{{ terraform_vm_project_path }}" + state: "{{ terraform_vm_state }}" + +- name: Refresh inventory + ansible.builtin.meta: refresh_inventory \ No newline at end of file