Add option to have two services in one role and add phpvms_test

This commit is contained in:
Tobias Reisinger 2026-02-09 23:20:17 +01:00
parent 8065273196
commit 4a71c9c170
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
8 changed files with 33 additions and 16 deletions

View file

@ -9,20 +9,20 @@ phpvms_gid: 1000
phpvms_app_key: "{{ undef() }}" phpvms_app_key: "{{ undef() }}"
phpvms_domain: "kondor-virtual.de"
phpvms_svc: phpvms_svc:
domain: "kondor-virtual.de" domain: "{{ phpvms_domain }}"
port: 80 port: 80
phpvms_env: phpvms_env:
WWWUSER: "{{ phpvms_uid }}" WWWUSER: "{{ phpvms_uid }}"
WWWGROUP: "{{ phpvms_gid }}" WWWGROUP: "{{ phpvms_gid }}"
CADDY_DOMAIN: "http://{{ svc.domain }}"
APP_KEY: "{{ phpvms_app_key | mandatory }}" APP_KEY: "{{ phpvms_app_key | mandatory }}"
APP_NAME: phpVMS APP_NAME: phpVMS
SITE_NAME: phpVMS SITE_NAME: phpVMS
APP_URL: "https://{{ svc.domain }}" APP_URL: "https://{{ phpvms_domain }}"
APP_LOCALE: de APP_LOCALE: de
APP_ENV: production APP_ENV: production
@ -143,12 +143,8 @@ phpvms_compose:
default: default:
mariadb: mariadb:
container_name: phpvms-mariadb
image: mariadb:11 image: mariadb:11
restart: always restart: always
# If someone need to access db from the outside
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment: environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}' MYSQL_DATABASE: '${DB_DATABASE}'
@ -167,7 +163,6 @@ phpvms_compose:
retries: 3 retries: 3
redis: redis:
container_name: phpvms-redis
image: redis:alpine image: redis:alpine
restart: always restart: always
networks: networks:

View file

@ -0,0 +1 @@
vmsacars.tar.gz

View file

@ -33,12 +33,14 @@
group: "{{ phpvms_gid }}" group: "{{ phpvms_gid }}"
become: true become: true
notify: Restart service {{ service_name }} notify: Restart service {{ service_name }}
when: service_name == role_name # Only use on "main" instance
- name: Copy Caddyfile - name: Template Caddyfile
ansible.builtin.copy: ansible.builtin.template:
src: Caddyfile src: Caddyfile.j2
dest: "{{ (service_path, 'Caddyfile') | path_join }}" dest: "{{ (service_path, 'Caddyfile') | path_join }}"
mode: "0644" mode: "0644"
notify: Restart service {{ service_name }}
- name: Import start tasks for common service - name: Import start tasks for common service
ansible.builtin.import_tasks: tasks/start-common-service.yml ansible.builtin.import_tasks: tasks/start-common-service.yml

View file

@ -1,4 +1,4 @@
{$CADDY_DOMAIN} { http://{{ phpvms_domain }} {
root * /var/www/html/public root * /var/www/html/public
encode zstd gzip encode zstd gzip

View file

@ -0,0 +1,2 @@
service_name_overwrite: phpvms_test # noqa: var-naming[no-role-prefix]
phpvms_domain: "test.kondor-virtual.de"

View file

@ -20,13 +20,16 @@
- name: Include service roles - name: Include service roles
ansible.builtin.include_role: ansible.builtin.include_role:
name: "{{ services_item }}" name: "{{ services_item.value.ansible_role | default(services_item.key, true) }}"
tasks_from: "{{ services_item.value.ansible_tasks | default(omit, true) }}"
vars_from: "{{ services_item.value.ansible_vars | default(omit, true) }}"
apply: apply:
tags: "{{ services_item }}" tags: "{{ services_item.key }}"
tags: always tags: always
loop: "{{ host_services | services_names() }}" loop: "{{ host_services | dict2items }}"
loop_control: loop_control:
loop_var: services_item loop_var: services_item
label: "{{ services_item.key }}"
- name: Reload caddy on caddy tag - name: Reload caddy on caddy tag
ansible.builtin.import_tasks: ansible.builtin.import_tasks:

View file

@ -641,6 +641,17 @@ services = {
mail = "phpvms@kondor-virtual.de" mail = "phpvms@kondor-virtual.de"
} }
"phpvms_test" = {
host = "node002"
dns = [{
domain = "airline-test.serguzim.me"
}]
auth = false
database = false
ansible_role = "phpvms"
ansible_vars = "test"
}
"postgresql" = { "postgresql" = {
host = "node001" host = "node001"
dns = [{ dns = [{

View file

@ -172,6 +172,9 @@ variable "services" {
mail = optional(string) mail = optional(string)
mail_smtp = optional(bool, true) mail_smtp = optional(bool, true)
mail_imap = optional(bool, false) mail_imap = optional(bool, false)
ansible_role = optional(string)
ansible_tasks = optional(string)
ansible_vars = optional(string)
})) }))
} }