Allow reusing service templates

This commit is contained in:
Kacper Donat 2022-10-28 22:32:16 +02:00
parent a517daa91b
commit 80957e4ac7
2 changed files with 8 additions and 8 deletions

View File

@ -1,7 +1,7 @@
--- ---
- name: 'Include vars for "{{ service }}" service' - name: 'Include vars for "{{ service }}" service'
include_vars: "{{ service_vars_file }}" include_vars: "{{ service_vars_file }}"
with_fileglob: "{{ services_root }}/{{ service }}/vars/*" with_fileglob: "{{ service_path }}/vars/*"
loop_control: loop_control:
loop_var: service_vars_file loop_var: service_vars_file
tags: tags:
@ -28,7 +28,7 @@
- name: 'Load configuration tasks for "{{ service }}"' - name: 'Load configuration tasks for "{{ service }}"'
include_tasks: "{{ service_task_file }}" include_tasks: "{{ service_task_file }}"
with_fileglob: "{{ services_root }}/{{ service }}/tasks/*" with_fileglob: "{{ service_path }}/tasks/*"
loop_control: loop_control:
loop_var: service_task_file loop_var: service_task_file
when: service_task_file|basename is not regex('^_') when: service_task_file|basename is not regex('^_')
@ -37,7 +37,7 @@
- name: 'Copy stack file of "{{ service }}" to remote server' - name: 'Copy stack file of "{{ service }}" to remote server'
template: template:
src: "{{ services_root }}/{{ service }}/stack.yml" src: "{{ service_path }}/stack.yml"
dest: "{{ remote_service_path }}/stack.yml" dest: "{{ remote_service_path }}/stack.yml"
tags: tags:
- deploy - deploy

View File

@ -1,8 +1,9 @@
--- ---
services_root: "{{ './services' | realpath }}" services_root: "{{ './services' | realpath }}"
service_path: "{{ services_root }}/{{ service }}" service_template: "{{ service_config[service].template | default(service) }}"
service_path: "{{ services_root }}/{{ service_template }}"
services: "{{ lookup('pipe', 'ls -1 ' + services_root).split('\n') | list }}" services: "{{ service_config | keys | list }}"
remote_services_root: /var/services remote_services_root: /var/services
remote_service_path: "{{ remote_services_root }}/{{ service }}" remote_service_path: "{{ remote_services_root }}/{{ service }}"
@ -109,13 +110,11 @@ service_config:
name: cojedzie name: cojedzie
user: cojedzie user: cojedzie
password: "{{ mysql_user_passwords['cojedzie'] }}" password: "{{ mysql_user_passwords['cojedzie'] }}"
cojedzie-next: cojedzie-next:
cojedzie_database: cojedzie_database:
name: cojedzie-next name: cojedzie-next
user: cojedzie-next user: cojedzie-next
password: "{{ mysql_user_passwords['cojedzie-next'] }}" password: "{{ mysql_user_passwords['cojedzie-next'] }}"
registry: registry:
registry_users: registry_users:
- "{{ swarm_registry_user }}" - "{{ swarm_registry_user }}"
@ -165,6 +164,7 @@ service_config:
region: eu-central-003 region: eu-central-003
regionendpoint: https://s3.eu-central-003.backblazeb2.com regionendpoint: https://s3.eu-central-003.backblazeb2.com
bucket: kadet-docker bucket: kadet-docker
portainer: ~
system: ~
www_data_users: www_data_users:
- vagrant - vagrant