Skip to content

Commit

Permalink
Merge pull request #1 from exterrestris/unmount-unlisted
Browse files Browse the repository at this point in the history
Optionally remove any existing mergerfs mounts that are not specified in mergerfs_mounts
  • Loading branch information
tigattack authored Nov 23, 2023
2 parents 5b4c8ae + e78fc90 commit 03ddc14
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ mergerfs_mounts:
options: allow_other,use_ino
```
### `mergerfs_remove_undefined_mounts`

Default: `false`

Remove any existing mergerfs mounts that are not listed in `mergerfs_mounts`

### `mergerfs_github_releases_url`

Default: [`https://github.com/trapexit/mergerfs/releases`](https://github.com/trapexit/mergerfs/releases)
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ mergerfs_github_releases_url: https://github.com/trapexit/mergerfs/releases

# Whether the role should install prerequisites for you.
mergerfs_install_prerequisites: true

# Whether mergerfs mounts not listed in `mergerfs_mounts` should be unmounted
mergerfs_remove_undefined_mounts: false
15 changes: 15 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,18 @@
loop: "{{ mergerfs_mounts }}"
become: true
tags: [mergerfs, mergerfs_install]

- name: Unmount unlisted mergerfs filesystems
block:
- name: List existing mergerfs filesystems
# ansible_mounts doesn't list fuse mounts
ansible.builtin.command: "findmnt -t fuse.mergerfs -o TARGET -n"
changed_when: false
register: existing_mergerfs_mounts
- name: Unmount mergerfs filesystems
ansible.posix.mount:
path: "{{ item }}"
state: absent
loop: "{{ existing_mergerfs_mounts.stdout_lines }}"
when: item not in mergerfs_mounts | map(attribute='path') | list
when: mergerfs_remove_undefined_mounts

0 comments on commit 03ddc14

Please sign in to comment.