move to new module setup #2
20 changed files with 9 additions and 64 deletions
|
@ -1,8 +0,0 @@
|
||||||
[defaults]
|
|
||||||
roles_path=roles
|
|
||||||
inventory=inventory
|
|
||||||
interpreter_python=/usr/bin/python3
|
|
||||||
vault_password_file=util/secret-service-client.sh
|
|
||||||
|
|
||||||
[diff]
|
|
||||||
always = True
|
|
|
@ -1 +0,0 @@
|
||||||
internal_ip: 192.168.30.7
|
|
|
@ -1,6 +0,0 @@
|
||||||
all:
|
|
||||||
hosts:
|
|
||||||
hermes:
|
|
||||||
ansible_connection: ssh
|
|
||||||
ansible_user: root
|
|
||||||
ansible_host: 192.168.30.7
|
|
|
@ -7,7 +7,7 @@
|
||||||
wait_for:
|
wait_for:
|
||||||
state: started
|
state: started
|
||||||
port: 22
|
port: 22
|
||||||
host: "{{ internal_ip }}"
|
host: "192.168.30.7"
|
||||||
timeout: 300
|
timeout: 300
|
||||||
connect_timeout: 300
|
connect_timeout: 300
|
||||||
search_regex: OpenSSH
|
search_regex: OpenSSH
|
52
main.tf
52
main.tf
|
@ -18,51 +18,11 @@ provider "libvirt" {
|
||||||
uri = "qemu+ssh://root@atlas.lan/system"
|
uri = "qemu+ssh://root@atlas.lan/system"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "libvirt_volume" "main_disk" {
|
module "vm" {
|
||||||
name = "${var.name}.iso"
|
source = "git::https://git.pim.kunis.nl/home/tf-modules.git//debian"
|
||||||
pool = "disk"
|
name = "hermes"
|
||||||
size = 1024 * 1024 * 1024 * 15
|
use_host_cert = false
|
||||||
base_volume_name = "debian-bookworm.qcow2"
|
fixed_address = "192.168.30.7/24"
|
||||||
base_volume_pool = "iso"
|
ansible_command = "ANSIBLE_ROLES_PATH=roles ANSIBLE_HOST_KEY_CHECKING=False ANSIBLE_VAULT_PASSWORD_FILE=util/secret-service-client.sh ansible-playbook -u root -i '192.168.30.7,' hermes.yml"
|
||||||
}
|
|
||||||
|
|
||||||
resource "libvirt_cloudinit_disk" "cloudinit" {
|
|
||||||
name = "${var.name}.iso"
|
|
||||||
pool = "init"
|
|
||||||
user_data = templatefile("cloud_init.cfg.tftpl", { name = var.name, admin_authorized_keys = var.admin_authorized_keys })
|
|
||||||
network_config = templatefile("network_config.cfg.tftpl", { internal_ip = var.internal_ip })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "libvirt_domain" "ubuntu" {
|
|
||||||
name = var.name
|
|
||||||
memory = 1024
|
|
||||||
vcpu = 4
|
|
||||||
autostart = true
|
|
||||||
|
|
||||||
disk {
|
|
||||||
volume_id = libvirt_volume.main_disk.id
|
|
||||||
}
|
|
||||||
|
|
||||||
network_interface {
|
|
||||||
bridge = "dmzbr"
|
|
||||||
hostname = var.name
|
|
||||||
mac = "CA:FE:C0:FF:EE:07"
|
mac = "CA:FE:C0:FF:EE:07"
|
||||||
}
|
|
||||||
|
|
||||||
cloudinit = libvirt_cloudinit_disk.cloudinit.id
|
|
||||||
|
|
||||||
provisioner "local-exec" {
|
|
||||||
command = "ansible-playbook -e internal_ip=${var.internal_ip} -T 60 -u root -i ${var.ansible_inventory} ${var.ansible_playbook}"
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
ANSIBLE_HOST_KEY_CHECKING = "False"
|
|
||||||
ANSIBLE_CONFIG = "${var.ansible_cfg}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lifecycle {
|
|
||||||
replace_triggered_by = [
|
|
||||||
libvirt_cloudinit_disk.cloudinit.id
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue