Split service deploy into user and deploy
This commit is contained in:
parent
fac7456fa1
commit
2982c54d69
12
playbooks/02a-services-common.yml
Normal file
12
playbooks/02a-services-common.yml
Normal 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
|
@ -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
|
|
@ -2,12 +2,8 @@
|
|||||||
- name: "Deploy services"
|
- name: "Deploy services"
|
||||||
hosts: the_nine_worlds
|
hosts: the_nine_worlds
|
||||||
|
|
||||||
vars:
|
|
||||||
- service_rproxy_hosts:
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- import_tasks: tasks/services/deploy/00-hosts.yml
|
- include_tasks: tasks/services/b-user/service-user.yml
|
||||||
- include_tasks: tasks/services/deploy/01-service.yml
|
|
||||||
with_items: "{{ host_services }}"
|
with_items: "{{ host_services }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: service_name
|
loop_var: service_name
|
10
playbooks/02c-services-deploy.yml
Normal file
10
playbooks/02c-services-deploy.yml
Normal 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
|
7
playbooks/tasks/services/b-user/service-user.yml
Normal file
7
playbooks/tasks/services/b-user/service-user.yml
Normal 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 }}"
|
@ -9,8 +9,8 @@
|
|||||||
- include_tasks: "{{ item }}"
|
- include_tasks: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
- "01-user.d/shell/{{ service_name }}.yml"
|
- "00-user.d/shell/{{ service_name }}.yml"
|
||||||
- "01-user.d/shell/_default.yml"
|
- "00-user.d/shell/_default.yml"
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
@ -52,8 +52,8 @@
|
|||||||
- include_tasks: "{{ item }}"
|
- include_tasks: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
- "01-user.d/data/{{ service_name }}.yml"
|
- "00-user.d/data/{{ service_name }}.yml"
|
||||||
- "01-user.d/data/_default.yml"
|
- "00-user.d/data/_default.yml"
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Create configuration directory for user {{ service_user_name }}
|
- name: Create configuration directory for user {{ service_user_name }}
|
@ -15,5 +15,5 @@
|
|||||||
- include_tasks: "{{ item }}"
|
- include_tasks: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
- "01-zfs-datasets.d/{{ service_name }}.yml"
|
- "00-zfs-datasets.d/{{ service_name }}.yml"
|
||||||
- "01-zfs-datasets.d/_default.yml"
|
- "00-zfs-datasets.d/_default.yml"
|
@ -1,3 +1,7 @@
|
|||||||
|
- name: Reset reverse proxy hosts variable
|
||||||
|
set_fact:
|
||||||
|
service_rproxy_hosts:
|
||||||
|
|
||||||
- name: Collect reverse proxy hosts
|
- name: Collect reverse proxy hosts
|
||||||
set_fact:
|
set_fact:
|
||||||
service_rproxy_hosts: "{{ service_rproxy_hosts }} --add-host=pod-{{ item.key }}:{{ item.value.address }}"
|
service_rproxy_hosts: "{{ service_rproxy_hosts }} --add-host=pod-{{ item.key }}:{{ item.value.address }}"
|
4
playbooks/tasks/services/c-deploy/01-service-deploy.yml
Normal file
4
playbooks/tasks/services/c-deploy/01-service-deploy.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- block:
|
||||||
|
- import_tasks: ../vars.yml
|
||||||
|
- import_tasks: service-deploy/service.yml
|
||||||
|
tags: "{{ service_name }}"
|
@ -1,9 +1,4 @@
|
|||||||
- block:
|
- 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
|
- name: Create database password
|
||||||
template:
|
template:
|
@ -1,9 +1,4 @@
|
|||||||
- block:
|
- 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
|
- name: Synchronise service configuration
|
||||||
copy:
|
copy:
|
@ -1,9 +1,4 @@
|
|||||||
- block:
|
- 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
|
- name: Synchronise service configuration
|
||||||
copy:
|
copy:
|
@ -1,7 +1,8 @@
|
|||||||
- block:
|
- block:
|
||||||
- name: Create configuration directory for user {{ service_user_name }}
|
|
||||||
|
- name: Create service configuration directory for {{ service_user_name }}
|
||||||
file:
|
file:
|
||||||
path: "{{ service_home }}/.config"
|
path: "{{ service_home }}/.config/{{ service_user_name }}"
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
@ -22,19 +23,7 @@
|
|||||||
when:
|
when:
|
||||||
local_service_path.stat.exists
|
local_service_path.stat.exists
|
||||||
|
|
||||||
- name: Create systemd directory for user {{ service_user_name }}
|
- name: Configure {{ service_user_name }} SystemD service
|
||||||
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
|
|
||||||
template:
|
template:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /{{ service_home }}/.config/systemd/user/{{ item | basename | regex_replace('\.j2','') }}
|
dest: /{{ service_home }}/.config/systemd/user/{{ item | basename | regex_replace('\.j2','') }}
|
||||||
@ -53,7 +42,7 @@
|
|||||||
- include_tasks: "{{ item }}"
|
- include_tasks: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
- "03-pod.d/{{ service_name }}.yml"
|
- "service.d/{{ service_name }}.yml"
|
||||||
skip: true
|
skip: true
|
||||||
|
|
||||||
- name: Enable the {{ service_name }} service
|
- name: Enable the {{ service_name }} service
|
@ -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 }}"
|
|
Loading…
Reference in New Issue
Block a user