Refactor services-to-host-mapping and playbooks

This commit is contained in:
Tobias Reisinger 2024-10-03 00:50:21 +02:00
parent 825393bbd3
commit a8e14b53f5
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
9 changed files with 142 additions and 108 deletions

View file

@ -0,0 +1,17 @@
class FilterModule(object):
def filters(self):
return {
'my_service_attributes': self.my_service_attributes,
}
def my_service_attributes(self, services, my_services, attribute="name"):
result = []
for service in services:
if service["name"] in my_services:
if attribute in service:
if type(service[attribute]) == list:
result.extend(service[attribute])
else:
result.append(service[attribute])
return result

View file

@ -1,63 +0,0 @@
---
- name: Run roles for node002
hosts: node002
roles:
- role: always
- role: backup
tags: backup
- role: lego
tags: lego
- role: caddy
tags: caddy
vars:
caddy_ports_extra:
- 8448:8448
- role: watchtower
tags: watchtower
- role: authentik
tags: authentik
- role: extra_services
tags: extra_services
- role: faas
tags: faas
- role: forgejo
tags: forgejo
- role: forgejo_runner
tags: forgejo_runner
- role: healthcheck
tags: healthcheck
- role: homebox
tags: homebox
- role: immich
tags: immich
- role: influxdb
tags: influxdb
- role: jellyfin
tags: jellyfin
- role: minio
tags: minio
- role: ntfy
tags: ntfy
- role: reitanlage_oranienburg
tags: reitanlage_oranienburg
- role: shlink
tags: shlink
- role: synapse
tags: synapse
- role: tandoor
tags: tandoor
- role: teamspeak_fallback
tags: teamspeak_fallback
- role: telegraf
tags: telegraf
- role: tinytinyrss
tags: tinytinyrss
- role: uptime_kuma
tags: uptime_kuma
- role: vikunja
tags: vikunja
- role: webhook
tags: webhook
- role: woodpecker
tags: woodpecker

View file

@ -1,24 +0,0 @@
---
- name: Run roles for node003
hosts: node003
roles:
- role: always
- role: docker
tags: common
- role: backup
tags: backup
- role: caddy
tags: caddy
- role: watchtower
tags: watchtower
- role: acme_dns
tags: acme-dns
- role: linkwarden
tags: linkwarden
- role: mailcow
tags: mailcow
- role: umami
tags: umami
- role: wiki_js
tags: wiki_js

View file

@ -1,6 +1,28 @@
---
- name: Run playbook for node001
import_playbook: node001.yml
- name: Run all roles
hosts: serguzim_net
tasks:
- name: Include common roles
ansible.builtin.include_role:
name: "{{ services_item }}"
apply:
tags: "{{ services_item }}"
tags: always
loop:
- always
- backup
- lego
- caddy
- watchtower
loop_control:
loop_var: services_item
- name: Run playbook for node002
import_playbook: node002.yml
- name: Include service roles
ansible.builtin.include_role:
name: "{{ services_item }}"
apply:
tags: "{{ services_item }}"
tags: always
loop: "{{ all_services | my_service_attributes(host_services) }}"
loop_control:
loop_var: services_item