Prevent ownership change when mount dir exists

This commit is contained in:
Wojciech Kozlowski 2022-11-03 19:33:18 +01:00
parent a3d318daa2
commit baa6583484
4 changed files with 44 additions and 2 deletions

View File

@ -6,7 +6,7 @@
group: "{{ service_user_name }}"
mode: 0755
- name: Create data directory for user {{ service_user_name }}
- name: Create nextcloud directory for user {{ service_user_name }}
file:
path: "/var/lib/{{ ansible_hostname }}/data/{{ service_user_name }}/nextcloud"
state: directory
@ -14,13 +14,20 @@
group: "{{ service_user_name }}"
mode: 0755
- name: Create data mount directory for user {{ service_user_name }}
- 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:
@ -30,6 +37,11 @@
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"
@ -37,3 +49,5 @@
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not data_mount_directory.stat.exists

View File

@ -14,6 +14,11 @@
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"
@ -21,6 +26,8 @@
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:
@ -30,6 +37,11 @@
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"
@ -37,3 +49,5 @@
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not data_mount_directory.stat.exists

View File

@ -14,6 +14,11 @@
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"
@ -21,3 +26,5 @@
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not etc_letsencrypt_mount_directory.stat.exists

View File

@ -14,6 +14,11 @@
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"
@ -21,3 +26,5 @@
owner: "{{ service_user_name }}"
group: "{{ service_user_name }}"
mode: 0755
when:
not etc_letsencrypt_mount_directory.stat.exists