Optimise volume setup

This commit is contained in:
Wojciech Kozlowski 2022-11-08 21:09:35 +01:00
parent 8dae9d4e76
commit 2cc62f57ec
14 changed files with 63 additions and 211 deletions

View File

@ -2,6 +2,20 @@
- name: "Deploy services"
hosts: the_nine_worlds
vars:
volumes:
rproxy:
- "etc-letsencrypt"
www: []
lrproxy:
- "etc-letsencrypt"
database:
- "wal"
- "data"
cloud:
- "nextcloud"
- "data"
tasks:
- include_tasks: tasks/services/b-user/service-user.yml
with_items: "{{ host_services }}"

View File

@ -1,7 +1,4 @@
- name: Create volume data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- include_tasks: _volumes.yml
with_items: "{{ volumes[service_name] }}"
loop_control:
loop_var: volume

View File

@ -0,0 +1,22 @@
- name: Create volume {{ volume }} for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/{{ volume }}"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Check if {{ volume }} mount directory exists for user {{ service_user_name }}
stat:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/{{ volume }}/_data"
register: volume_mount_directory
- name: Create {{ volume }} mount directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/{{ volume }}/_data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not volume_mount_directory.stat.exists

View File

@ -1,53 +0,0 @@
- name: Create volume data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Create nextcloud directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/nextcloud"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Check if nextcloud mount directory exists for user {{ service_user_name }}
stat:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/nextcloud/_data"
register: nextcloud_mount_directory
- name: Create nextcloud mount directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/nextcloud/_data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not nextcloud_mount_directory.stat.exists
- name: Create data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Check if data mount directory exists for user {{ service_user_name }}
stat:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/data/_data"
register: data_mount_directory
- name: Create data mount directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/data/_data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not data_mount_directory.stat.exists

View File

@ -1,53 +0,0 @@
- name: Create volume data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Create wal directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/wal"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Check if wal mount directory exists for user {{ service_user_name }}
stat:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/wal/_data"
register: wal_mount_directory
- name: Create wal mount directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/wal/_data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not wal_mount_directory.stat.exists
- name: Create data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Check if data mount directory exists for user {{ service_user_name }}
stat:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/data/_data"
register: data_mount_directory
- name: Create data mount directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/data/_data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not data_mount_directory.stat.exists

View File

@ -1,30 +0,0 @@
- name: Create volume data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Create etc-letsencrypt directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/etc-letsencrypt"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Check if etc-letsencrypt mount directory exists for user {{ service_user_name }}
stat:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/etc-letsencrypt/_data"
register: etc_letsencrypt_mount_directory
- name: Create etc-letsencrypt mount directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/etc-letsencrypt/_data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not etc_letsencrypt_mount_directory.stat.exists

View File

@ -1,30 +0,0 @@
- name: Create volume data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Create etc-letsencrypt directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/etc-letsencrypt"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- name: Check if etc-letsencrypt mount directory exists for user {{ service_user_name }}
stat:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/etc-letsencrypt/_data"
register: etc_letsencrypt_mount_directory
- name: Create etc-letsencrypt mount directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/etc-letsencrypt/_data"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not etc_letsencrypt_mount_directory.stat.exists

View File

@ -49,6 +49,14 @@
group: "{{ service_user_name }}"
mode: 0755
- name: Create volume data directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}"
state: directory
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
- include_tasks: "{{ item }}"
with_first_found:
- files:

View File

@ -1,4 +1,4 @@
- name: Create volume data dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}
state: present
- include_tasks: _volumes.yml
with_items: "{{ volumes[service_name] }}"
loop_control:
loop_var: volume

View File

@ -0,0 +1,4 @@
- name: Create {{ volume }} dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/{{ volume }}
state: present

View File

@ -1,16 +0,0 @@
- name: Create data dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}
state: present
extra_zfs_properties:
canmount: "off"
- name: Create app dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/nextcloud
state: present
- name: Create data dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/data
state: present

View File

@ -1,10 +1,3 @@
- name: Create data dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}
state: present
extra_zfs_properties:
canmount: "off"
- name: Create wal dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/wal

View File

@ -1,11 +0,0 @@
- name: Create data dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}
state: present
extra_zfs_properties:
canmount: "off"
- name: Create etc-letsencrypt dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/etc-letsencrypt
state: present

View File

@ -12,6 +12,13 @@
when:
user_zfs_home is changed
- name: Create data dataset for user {{ service_user_name }}
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}
state: present
extra_zfs_properties:
canmount: "off"
- include_tasks: "{{ item }}"
with_first_found:
- files: