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

83 lines
2.6 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: Transmission
### ⇐ UPSTREAM BEGIN ###
- name: make sure that Transmission shared directories exist
file:
path: "{{item}}"
state: directory
with_items:
- "{{transmission_real_done_at}}"
- "{{transmission_real_todo_at}}"
- name: mount the exported directories
mount:
src: "{{item.from}}"
path: '{{item.to}}'
state: mounted
fstype: none
opts: 'bind,x-systemd.requires-mounts-for={{item.from}},x-systemd.requires-mounts-for={{item.to | dirname}}'
dump: 0
passno: 0
with_items:
- {from: "{{transmission_real_done_at}}", to: "/srv/nfs/{{transmission_nfs_done_at}}"}
- {from: "{{transmission_real_todo_at}}", to: "/srv/nfs/{{transmission_nfs_todo_at}}"}
when:
- ((item.from | truncate(8, True, '', 0)) != '/srv/nfs')
notify:
- restart nfs-server.service
- name: set the nfs-server dependencies on the mount points
lineinfile:
path: /etc/systemd/system/nfs-server.service.d/mount-transmission.conf
create: true
mode: 0660
line: RequiresMountsFor={{item.to}}
insertafter: EOF
with_items:
- {from: "{{transmission_real_done_at}}", to: "/srv/nfs/{{transmission_nfs_done_at}}"}
- {from: "{{transmission_real_todo_at}}", to: "/srv/nfs/{{transmission_nfs_todo_at}}"}
when:
- ((item.from | truncate(8, True, '', 0)) != '/srv/nfs')
notify:
- restart nfs-server.service
- name: make the nfs-server dependencies file syntactically correct
lineinfile:
path: /etc/systemd/system/nfs-server.service.d/mount-transmission.conf
create: false
line: '[Unit]'
insertbefore: BOF
ignore_errors: true
### UPSTREAM END ⇒ ###
- name: merge upstream
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=merge.yml
vars:
msg: Transmission
### ⇐ UPSTREAM END ###
- name: make NFS see these directories
template:
src: templates/exports.j2
dest: /etc/exports.d/{{nickname}}_transmission.exports
mode: 0600
notify:
- restart nfs-server.service
### LOCAL COMMIT ⇒ ###
- name: commit local changes
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=local.yml
vars:
msg: Transmission
### ⇐ LOCAL COMMIT ###
- meta: flush_handlers