diff --git a/defaults/main.yml b/defaults/main.yml index 2b7728e3488ccdad218b564a29dd70460fccc67a..b67dbc3447c5ecc1dbc763585dda48d1f71402f6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -28,3 +28,6 @@ drupal_post_deploy_tasks: letsencrypt_pause_services: - 'apache2' + +fstype_convert: + btrfs: 'btrfs-convert --no-progress {{ item.src }}' diff --git a/tasks/files.yml b/tasks/files.yml index e1d1dce70feadf0c345f72349131b474ab73b74c..9cfc390dbe387d192a91a3996f1f8fb3934e61f0 100644 --- a/tasks/files.yml +++ b/tasks/files.yml @@ -6,29 +6,14 @@ src='{{ relativeRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' dest='{{ drupalRoot }}/sites/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' -- block: - - - name: "Ensure mounted and webroot file directory" - file: - dest='{{ item }}' - state='directory' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' - with_items: - - '{{ drupal_domain.0.mountpoint }}' - - '{{ webRoot }}/files' - ignore_errors: yes - - - name: "Link webroot to mounted directory" - file: - src='{{ drupal_domain.0.mountpoint }}/{{ drupal_domain.0.shortname|default("default") }}' - dest='{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}' - state='link' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' - +- name: "Link webroot to mounted directory" + file: + src='{{ drupal_domain.0.mountpoint }}/{{ drupal.id }}/{{ drupal_domain.0.shortname|default("default") }}' + dest='{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}' + state='link' + owner='{{ apacheUser }}' + group='{{ apacheUser }}' + mode='755' when: drupal_domain.0.mountpoint is defined - name: "Ensure File Directories" diff --git a/tasks/install.yml b/tasks/install.yml index 15176c6af10b366344c5816593313ed1a7edcb01..084888d4cad632defd5607a912a56241ed173da6 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -117,6 +117,19 @@ with_items: '{{ drupal.domains }}' when: item.install|default(true) +- name: "Ensure Files Directory" + file: + path='{{ webRoot }}/files' + state='directory' + owner='{{ apacheUser }}' + group='{{ apacheUser }}' + mode='775' + when: drupal.install_extra_dirs|default(true) + +- include_tasks: mountpoints.yml + with_items: '{{ drupal.mountpoints|default[] }}' + when: drupal.install_extra_dirs|default(true) + - include_tasks: files.yml with_nested: - '{{ drupal.domains }}' diff --git a/tasks/mountpoints.yml b/tasks/mountpoints.yml new file mode 100644 index 0000000000000000000000000000000000000000..dd7ba237b9022a03c96c8831b10d8d7ca59bc024 --- /dev/null +++ b/tasks/mountpoints.yml @@ -0,0 +1,52 @@ +--- +# file: roles/drupal/tasks/mountpoints.yml + +- name: "Check File System Type" + shell: 'lsblk --noheadings --fs --output FSTYPE {{ item.src }}' + register: fstype + +- name: "Convert File System Type" + shell: '{{ fstype_convert[item.fstype] }}' + when: item.fstype != fstype + +- name: "Ensure directory for mountpoint" + file: + dest: '{{ item.path }}' + state: 'directory' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: '755' + +- name: "Ensure directory for mountpoint in jail" + file: + dest: '{{ jailroot }}/{{ drupal.jail.name }}{{ item.path }}' + state: 'directory' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: '755' + when: drupal.jail is defined + +- name: "Mount the item" + mount: + path: '{{ item.path }}' + src: '{{ item.src }}' + fstype: '{{ item.fstype }}' + opts: '{{ item.opts|default(omit) }}' + state: 'mounted' + +- name: "Mount the item in jail" + mount: + path: '{{ jailroot }}/{{ drupal.jail.name }}{{ item.path }}' + src: '{{ item.src }}' + fstype: '{{ item.fstype }}' + opts: '{{ item.opts|default(omit) }}' + state: 'mounted' + when: drupal.jail is defined + +- name: "Ensure file directory in mountpoint" + file: + dest: '{{ item.path }}/{{ drupal.id }}' + state: 'directory' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: '755'