Split service deploy into user and deploy

This commit is contained in:
Wojciech Kozlowski 2022-10-30 21:08:41 +01:00
parent fac7456fa1
commit 2982c54d69
32 changed files with 49 additions and 62 deletions

View File

@ -0,0 +1,12 @@
---
- name: "Setup hosts for services"
hosts: the_nine_worlds
tasks:
- import_tasks: tasks/services/a-common/00-podman.yml
- import_tasks: tasks/services/a-common/01-zfs-datasets.yml
when: is_zfs
- import_tasks: tasks/services/a-common/01-directories.yml
- import_tasks: tasks/services/a-common/02-nameserver.yml
- import_tasks: tasks/services/a-common/03-systemd-veth.yml
- import_tasks: tasks/services/a-common/04-systemd-user.yml

View File

@ -1,12 +0,0 @@
---
- name: "Setup hosts for services"
hosts: the_nine_worlds
tasks:
- import_tasks: tasks/services/setup/00-podman.yml
- import_tasks: tasks/services/setup/01-zfs-datasets.yml
when: is_zfs
- import_tasks: tasks/services/setup/01-directories.yml
- import_tasks: tasks/services/setup/02-nameserver.yml
- import_tasks: tasks/services/setup/03-systemd-veth.yml
- import_tasks: tasks/services/setup/04-systemd-user.yml

View File

@ -2,12 +2,8 @@
- name: "Deploy services"
hosts: the_nine_worlds
vars:
- service_rproxy_hosts:
tasks:
- import_tasks: tasks/services/deploy/00-hosts.yml
- include_tasks: tasks/services/deploy/01-service.yml
- include_tasks: tasks/services/b-user/service-user.yml
with_items: "{{ host_services }}"
loop_control:
loop_var: service_name

View File

@ -0,0 +1,10 @@
---
- name: "Deploy services"
hosts: the_nine_worlds
tasks:
- import_tasks: tasks/services/c-deploy/00-hosts.yml
- include_tasks: tasks/services/c-deploy/01-service-deploy.yml
with_items: "{{ host_services }}"
loop_control:
loop_var: service_name

View File

@ -0,0 +1,7 @@
- block:
- import_tasks: ../vars.yml
- import_tasks: service-user/00-zfs-datasets.yml
when: is_zfs
- import_tasks: service-user/00-user.yml
- import_tasks: service-user/01-veth.yml
tags: "{{ service_name }}"

View File

@ -9,8 +9,8 @@
- include_tasks: "{{ item }}"
with_first_found:
- files:
- "01-user.d/shell/{{ service_name }}.yml"
- "01-user.d/shell/_default.yml"
- "00-user.d/shell/{{ service_name }}.yml"
- "00-user.d/shell/_default.yml"
- block:
@ -52,8 +52,8 @@
- include_tasks: "{{ item }}"
with_first_found:
- files:
- "01-user.d/data/{{ service_name }}.yml"
- "01-user.d/data/_default.yml"
- "00-user.d/data/{{ service_name }}.yml"
- "00-user.d/data/_default.yml"
- block:
- name: Create configuration directory for user {{ service_user_name }}

View File

@ -15,5 +15,5 @@
- include_tasks: "{{ item }}"
with_first_found:
- files:
- "01-zfs-datasets.d/{{ service_name }}.yml"
- "01-zfs-datasets.d/_default.yml"
- "00-zfs-datasets.d/{{ service_name }}.yml"
- "00-zfs-datasets.d/_default.yml"

View File

@ -1,3 +1,7 @@
- name: Reset reverse proxy hosts variable
set_fact:
service_rproxy_hosts:
- name: Collect reverse proxy hosts
set_fact:
service_rproxy_hosts: "{{ service_rproxy_hosts }} --add-host=pod-{{ item.key }}:{{ item.value.address }}"

View File

@ -0,0 +1,4 @@
- block:
- import_tasks: ../vars.yml
- import_tasks: service-deploy/service.yml
tags: "{{ service_name }}"

View File

@ -1,9 +1,4 @@
- block:
- name: Create service configuration directory for {{ service_user_name }}
file:
path: "{{ service_home }}/.config/{{ service_user_name }}"
state: directory
mode: 0755
- name: Create database password
template:

View File

@ -1,9 +1,4 @@
- block:
- name: Create service configuration directory for {{ service_user_name }}
file:
path: "{{ service_home }}/.config/{{ service_user_name }}"
state: directory
mode: 0755
- name: Synchronise service configuration
copy:

View File

@ -1,9 +1,4 @@
- block:
- name: Create service configuration directory for {{ service_user_name }}
file:
path: "{{ service_home }}/.config/{{ service_user_name }}"
state: directory
mode: 0755
- name: Synchronise service configuration
copy:

View File

@ -1,7 +1,8 @@
- block:
- name: Create configuration directory for user {{ service_user_name }}
- name: Create service configuration directory for {{ service_user_name }}
file:
path: "{{ service_home }}/.config"
path: "{{ service_home }}/.config/{{ service_user_name }}"
state: directory
mode: 0755
@ -22,19 +23,7 @@
when:
local_service_path.stat.exists
- name: Create systemd directory for user {{ service_user_name }}
file:
path: "{{ service_home }}/.config/systemd"
state: directory
mode: 0755
- name: Create systemd service directory for user {{ service_user_name }}
file:
path: "{{ service_home }}/.config/systemd/user"
state: directory
mode: 0755
- name: Configure {{ service_user_name }} service
- name: Configure {{ service_user_name }} SystemD service
template:
src: "{{ item }}"
dest: /{{ service_home }}/.config/systemd/user/{{ item | basename | regex_replace('\.j2','') }}
@ -53,7 +42,7 @@
- include_tasks: "{{ item }}"
with_first_found:
- files:
- "03-pod.d/{{ service_name }}.yml"
- "service.d/{{ service_name }}.yml"
skip: true
- name: Enable the {{ service_name }} service

View File

@ -1,8 +0,0 @@
- block:
- import_tasks: service/00-vars.yml
- import_tasks: service/01-zfs-datasets.yml
when: is_zfs
- import_tasks: service/01-user.yml
- import_tasks: service/02-veth.yml
- import_tasks: service/03-pod.yml
tags: "{{ service_name }}"