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

View File

@ -1,6 +1,7 @@
version: '3' version: '3'
services: services:
db_recipes: recipes_db:
container_name: recipes_db
image: postgres:11-alpine image: postgres:11-alpine
restart: always restart: always
volumes: volumes:
@ -8,7 +9,8 @@ services:
env_file: env_file:
- ./tandoor.env - ./tandoor.env
web_recipes: recipes_web:
container_name: recipes_web
image: vabene1111/recipes image: vabene1111/recipes
restart: always restart: always
env_file: env_file:
@ -18,21 +20,22 @@ services:
- nginx_config:/opt/recipes/nginx/conf.d - nginx_config:/opt/recipes/nginx/conf.d
- ./mediafiles:/opt/recipes/mediafiles - ./mediafiles:/opt/recipes/mediafiles
depends_on: depends_on:
- db_recipes - recipes_db
nginx_recipes: recipes_nginx:
container_name: recipes_nginx
image: nginx:mainline-alpine image: nginx:mainline-alpine
restart: always restart: always
env_file: env_file:
- ./.env - ./tandoor.env
depends_on:
- web_recipes
volumes: volumes:
- nginx_config:/etc/nginx/conf.d:ro - nginx_config:/etc/nginx/conf.d:ro
- staticfiles:/static:ro - staticfiles:/static:ro
- ./mediafiles:/media:ro - ./mediafiles:/media:ro
ports: ports:
- 1080:80 - 1080:80
depends_on:
- web_recipes
volumes: volumes:
nginx_config: 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" 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" { resource "local_file" "ansible_inventory" {
content = templatefile("../../templates/hosts.tmpl", 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 = [ media_managers = [
for ip in proxmox_vm_qemu.media-manager.*.ifconfig0 : 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 ip
) )
] ]
media_servers = [ media_servers = [
for ip in proxmox_vm_qemu.media-server.*.ifconfig0 : 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 ip
) )
] ]
home_apps = [ home_apps = [
for ip in proxmox_vm_qemu.main-docker.*.ifconfig0 : 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 ip
) )
] ]
} }
) )
filename = "../../applications/hosts" 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 } %{ for ip in home_apps }
${ ip } ${ ip }
%{ end for } %{ end for }
[pi-hole]
%{ for ip in piholes }
${ ip }
%{ end for }