Skip to content

Commit

Permalink
feat: ensure local mount path exists
Browse files Browse the repository at this point in the history
Adds a task to ensure the local mount path exists with optionally configurable mode, owner, and group.
  • Loading branch information
tigattack authored Oct 12, 2024
1 parent 666c0a2 commit 46c825c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ Note: This example assumes you have created the `rclone.service` systemd unit yo

### `rclone_mounts: ""`

This variable allows for the configuration of rclone mounts within your infrastructure. `rclone_mounts` should be a YAML list of objects, each including keys for `name`, `remote_name`, `remote_path`, `local_path`, `auto_mount`, and `extra_args`. This setup enables precise control over multiple mount points, their remote sources, and whether they should be automatically mounted.
This variable allows for the configuration of rclone mounts within your infrastructure. `rclone_mounts` should be a YAML list of objects, each including keys for `name`, `remote_name`, `remote_path`, `local_path`, `auto_mount`, and `extra_args`. Optionally, you can also pass `local_path_mode` (defaults to `0755`), `local_path_owner`, and `local_path_group` (both default to `root`).

This setup enables precise control over multiple mount points, their remote sources, and whether they should be automatically mounted.

If you use this variable, you must run this role as root using `become: true`.

Expand All @@ -227,6 +229,9 @@ rclone_mounts:
remote_name: BackblazeLM
remote_path: "/my-app"
local_path: "/var/backups/my-app/"
local_path_mode: 0755
local_path_owner: root
local_path_group: root
auto_mount: true
extra_args: "--allow-other"
```
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ rclone_mounts: []
# - name: test
# remote_path: "/test"
# local_path: "/mnt"
# local_path_mode: 0755
# local_path_owner: root
# local_path_group: root
# auto_mount: true
# extra_args: "--allow-other"
9 changes: 9 additions & 0 deletions tasks/mount.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
register: rclone_mkdir_output
changed_when: rclone_mkdir_output.rc == 0

- name: Ensure local path exists
ansible.builtin.file:
path: "{{ item.local_path }}"
mode: "{{ item.local_path_mode | default('0755') }}"
owner: "{{ item.local_path_owner | default('root') }}"
group: "{{ item.local_path_group | default('root') }}"
state: directory
loop: "{{ rclone_mounts }}"

- name: Install fuse
ansible.builtin.package:
name: fuse
Expand Down

0 comments on commit 46c825c

Please sign in to comment.