Compare commits

..

No commits in common. "95dce43d40f90e5422cd0854ca68ad3fa4513e8c" and "b5ccfd973ec16c4d46fedd070cafeeaeb6253c22" have entirely different histories.

5 changed files with 26 additions and 43 deletions

View file

@ -2,21 +2,9 @@
- hosts: all - hosts: all
gather_facts: no gather_facts: no
tasks: tasks:
- name: Wait for host to come up - name: Wait for cloud init to finish
wait_for: pause:
state: started seconds: 120
port: 22
host: "{{ internal_ip }}"
delay: 10
timeout: 300
connect_timeout: 300
search_regex: OpenSSH
delegate_to: localhost
- name: Wait for cloud-init to finish
command:
cmd: cloud-init status --wait
- name: Gather facts
setup:
- name: Update repositories - name: Update repositories
apt: apt:
autoremove: true autoremove: true
@ -24,12 +12,6 @@
state: latest state: latest
update_cache: yes update_cache: yes
cache_valid_time: 86400 # One day cache_valid_time: 86400 # One day
- name: Install packages
apt:
pkg:
- qemu-guest-agent
- dnsmasq
- dnsutils
- name: Disable systemd-resolved - name: Disable systemd-resolved
systemd: systemd:
name: systemd-resolved name: systemd-resolved

View file

@ -1,7 +1,17 @@
#cloud-config #cloud-config
hostname: "${name}" hostname: dns
manage_etc_hosts: true manage_etc_hosts: true
ssh_pwauth: false ssh_pwauth: false
disable_root: false disable_root: false
ssh_authorized_keys: ssh_authorized_keys:
- "${host_public_key}" - "${host_public_key}"
chpasswd:
list: |
root:root
expire: False
packages:
- qemu-guest-agent
- dnsmasq
- dnsutils
package_update: true
package_upgrade: true

View file

@ -15,9 +15,9 @@ domain=dmz
# IPv4 DHCP range # IPv4 DHCP range
dhcp-range=192.168.30.100,192.168.30.200,infinite dhcp-range=192.168.30.100,192.168.30.200,infinite
# Predefined DHCP hosts # Predefined DHCP hosts
dhcp-host=b8:27:eb:b9:ab:e2,esrom dhcp-host=b8:27:eb:b9:ab:e2,esrom,192.168.30.2
dhcp-host=b4:2e:99:77:1b:da,max dhcp-host=b4:2e:99:77:1b:da,max,192.168.30.3
dhcp-host=d8:5e:d3:47:33:6e,lewis dhcp-host=d8:5e:d3:47:33:6e,lewis,192.168.30.6
# Advertise router # Advertise router
dhcp-option=3,192.168.30.1 dhcp-option=3,192.168.30.1
# Always send the IPv6 DNS server address (this machine) # Always send the IPv6 DNS server address (this machine)
@ -36,4 +36,4 @@ server=/pim.kunis.nl/192.168.30.3
log-dhcp log-dhcp
log-queries log-queries
# Resolve dns.dmz to addresses on main NIC # Resolve dns.dmz to addresses on main NIC
interface-name=hermes.dmz,ens3 interface-name=dns.dmz,ens3

23
main.tf
View file

@ -29,11 +29,11 @@ resource "libvirt_cloudinit_disk" "cloudinit" {
name = "${var.name}.iso" name = "${var.name}.iso"
pool = "init" pool = "init"
user_data = templatefile("cloud_init.cfg.tftpl", { name = var.name, host_public_key = var.host_public_key }) user_data = templatefile("cloud_init.cfg.tftpl", { name = var.name, host_public_key = var.host_public_key })
network_config = templatefile("network_config.cfg.tftpl", { internal_ip = var.internal_ip }) network_config = templatefile("network_config.cfg.tftpl", { internal_ip = var.internal_ip})
} }
resource "libvirt_domain" "ubuntu" { resource "libvirt_domain" "ubuntu" {
name = "hermes" name = var.name
memory = 1024 memory = 1024
vcpu = 4 vcpu = 4
@ -42,24 +42,15 @@ resource "libvirt_domain" "ubuntu" {
} }
network_interface { network_interface {
bridge = "dmzbr" network_name = "dmzbr"
hostname = var.name hostname = "dns"
mac = "CA:FE:C0:FF:EE:07" addresses = ["${var.internal_ip}/24"]
mac = "ca:fe:c0:ff:ee:07"
} }
cloudinit = libvirt_cloudinit_disk.cloudinit.id cloudinit = libvirt_cloudinit_disk.cloudinit.id
provisioner "local-exec" { provisioner "local-exec" {
command = "ansible-playbook -e internal_ip=${var.internal_ip} -T 60 -u root -i inventory hermes.yml" command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -T 60 -u root -i inventory ansible.yml"
environment = {
ANSIBLE_HOST_KEY_CHECKING = "False"
}
}
lifecycle {
replace_triggered_by = [
libvirt_cloudinit_disk.cloudinit.id
]
} }
} }

View file

@ -1,5 +1,5 @@
variable "name" { variable "name" {
default = "hermes" default = "dmzdns"
} }
variable "libvirt_endpoint" { variable "libvirt_endpoint" {