home-server/roles/nextcloud_davfs/tasks/main.yml

59 lines
2.2 KiB
YAML

---
# The home-server project produces a multi-purpose setup using Ansible.
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
### UPSTREAM BEGIN ⇒ ###
- name: pull prerequisites from upstream
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=upstream.yml
vars:
msg: automount Nextcloud with davfs2
### ⇐ UPSTREAM BEGIN ###
- name: install packages
package:
name: "{{item}}"
state: present
with_items:
- davfs2
- pam_mount
### UPSTREAM END ⇒ ###
- name: merge upstream
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=merge.yml
vars:
msg: automount Nextcloud with davfs2
### ⇐ UPSTREAM END ###
- name: add the Nextcloud volume to pam_mount
lineinfile:
path: /etc/security/pam_mount.conf.xml
regexp: '<volume .*{{net_soa}}{{http_pfx_nextcloud}}'
line: >
<volume uid="1000-60000"
fstype="davfs" options="uid=%(USERUID),username=%(USER)"
path="https://{{net_soa}}{{http_pfx_nextcloud}}/remote.php/dav/files/%(USER)/"
mountpoint="/home/%(USER)/Nextcloud"/>
insertbefore: '</pam_mount>'
- name: configure PAM for auto-mounting
lineinfile:
path: '/etc/pam.d/{{item.file}}'
regexp: '^{{item.name}}\s.*pam_mount'
line: '{{item.name}}{{item.pad}}optional pam_mount.so'
insertafter: '{{item.after}}'
with_items:
- {file: 'system-auth', name: 'auth', pad: ' ', after: '^#%PAM'}
- {file: 'system-auth', name: 'session', pad: ' ', after: '^session.*required'}
- {file: 'su', name: 'auth', pad: ' ', after: '^auth.*sufficient.*pam_rootok.so'}
- {file: 'su', name: 'session', pad: ' ', after: '^sess.*required.*pam_mkhomedir.so'}
- {file: 'su-l', name: 'auth', pad: ' ', after: '^auth.*sufficient.*pam_rootok.so'}
- {file: 'su-l', name: 'session', pad: ' ', after: '^sess.*required.*pam_mkhomedir.so'}
### LOCAL COMMIT ⇒ ###
- name: commit local changes
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=local.yml
vars:
msg: automount Nextcloud with davfs2
### ⇐ LOCAL COMMIT ###