add pi-hole vm; add guest agent

This commit is contained in:
Ryan Goodwin 2022-06-14 14:15:07 -04:00
parent 359ce7dd95
commit 728a4969ad
4 changed files with 73 additions and 15 deletions

View File

@ -1,4 +1,12 @@
---
# QEMU Guest Agent
- name: Install Guest Agent
apt:
name:
- qemu-guest-agent
update_cache: yes
state: present
# Docker
- name: Install prerequisites
apt:
@ -8,6 +16,7 @@
- curl
- gnupg-agent
- software-properties-common
state: present
update_cache: yes
- name: Add docker apt-key
@ -24,6 +33,7 @@
- docker-ce
- docker-ce-cli
- containerd.io
state: present
update_cache: yes
- name: Ddd user permissions
@ -33,6 +43,7 @@
- name: Install Python package manager
apt:
name: python3-pip
state: present
- name: Install Python SDK
become_user: "{{ lookup('env', 'USER') }}"
@ -40,6 +51,7 @@
name:
- docker
- docker-compose
state: present
# Containers
- include_tasks: containers.yml

View File

@ -1,6 +1,7 @@
version: '3'
services:
db_recipes:
recipes_db:
container_name: recipes_db
image: postgres:11-alpine
restart: always
volumes:
@ -8,7 +9,8 @@ services:
env_file:
- ./tandoor.env
web_recipes:
recipes_web:
container_name: recipes_web
image: vabene1111/recipes
restart: always
env_file:
@ -18,21 +20,22 @@ services:
- nginx_config:/opt/recipes/nginx/conf.d
- ./mediafiles:/opt/recipes/mediafiles
depends_on:
- db_recipes
- recipes_db
nginx_recipes:
recipes_nginx:
container_name: recipes_nginx
image: nginx:mainline-alpine
restart: always
env_file:
- ./.env
depends_on:
- web_recipes
- ./tandoor.env
volumes:
- nginx_config:/etc/nginx/conf.d:ro
- staticfiles:/static:ro
- ./mediafiles:/media:ro
ports:
- 1080:80
depends_on:
- web_recipes
volumes:
nginx_config:

View File

@ -85,33 +85,71 @@ resource "proxmox_vm_qemu" "media-manager" {
ipconfig0 = "ip=192.168.0.51/24,gw=192.168.0.1"
}
resource "proxmox_vm_qemu" "pi_hole" {
count = 1
name = "pihole-${count.index + 1}"
vmid = "202"
target_node = "recyclebin"
clone = "ubuntu-2004-cloud"
agent = 1
os_type = "cloud-init"
cores = 2
sockets = 1
cpu = "host"
memory = 2048
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
disk {
slot = 0
size = "15G"
type = "scsi"
storage = "local-lvm"
iothread = 1
}
network {
model = "virtio"
bridge = "vmbr0"
}
lifecycle {
ignore_changes = [
network,
]
}
ipconfig0 = "ip=192.168.0.36/24,gw=192.168.0.1"
}
resource "local_file" "ansible_inventory" {
content = templatefile("../../templates/hosts.tmpl",
{
# Old regex = (\\b25[0-5]|\\b2[0-4][0-9]|\\b[01]?[0-9][0-9]?)(\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}
media_managers = [
for ip in proxmox_vm_qemu.media-manager.*.ifconfig0 :
regex("(\\b25[0-5]|\\b2[0-4][0-9]|\\b[01]?[0-9][0-9]?)(\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}",
regex("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}",
ip
)
]
media_servers = [
for ip in proxmox_vm_qemu.media-server.*.ifconfig0 :
regex("(\\b25[0-5]|\\b2[0-4][0-9]|\\b[01]?[0-9][0-9]?)(\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}",
regex("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}",
ip
)
]
home_apps = [
for ip in proxmox_vm_qemu.main-docker.*.ifconfig0 :
regex("(\\b25[0-5]|\\b2[0-4][0-9]|\\b[01]?[0-9][0-9]?)(\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}",
regex("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}",
ip
)
]
pi_holes = [
for ip in proxmox_vm_qemu.pi_hole.*.ifconfig0 :
regex("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}",
ip
)
]
}
)
filename = "../../applications/hosts"
depends_on = [
proxmox_vm_qemu.media-manager,
proxmox_vm_qemu.media_servers
]
}

View File

@ -12,3 +12,8 @@ ${ ip }
%{ for ip in home_apps }
${ ip }
%{ end for }
[pi-hole]
%{ for ip in piholes }
${ ip }
%{ end for }