add terransible project

This commit is contained in:
Vezpi 2025-03-26 21:47:02 +00:00
parent 8c793d3d59
commit de457e8e38
5 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,14 @@
---
- name: Deploy a Terraform infrastructure
hosts: localhost
tasks:
- name: terraform apply
cloud.terraform.terraform:
project_path: /home/vez/homelab/terraform/projects/terransible
state: present
register: tf_return
- name: Ping
hosts: servers
tasks:
- ping:

View File

@ -0,0 +1,2 @@
---
plugin: cloud.terraform.terraform_provider

View File

@ -0,0 +1,24 @@
module "pve_vm" {
source = "../../modules/pve_vm"
node_name = "zenith"
vm_name = "zenith-vm"
vm_cpu = 2
vm_ram = 2048
vm_vlan = 66
}
output "vm_ip" {
value = module.pve_vm.vm_ip
}
resource "ansible_group" "servers" {
name = "servers"
}
resource "ansible_host" "vm" {
name = "zenith-vm.lab.vezpi.me"
groups = ["servers"]
variables = {
ansible_host = module.pve_vm.vm_ip
}
}

View File

@ -0,0 +1,21 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
}
ansible = {
source = "ansible/ansible"
}
}
}
provider "proxmox" {
endpoint = var.proxmox_endpoint
api_token = var.proxmox_api_token
insecure = false
ssh {
agent = false
private_key = file("~/.ssh/id_ed25519")
username = "root"
}
}

View File

@ -0,0 +1,10 @@
variable "proxmox_endpoint" {
description = "Proxmox URL endpoint"
type = string
}
variable "proxmox_api_token" {
description = "Proxmox API token"
type = string
sensitive = true
}