Init
This commit is contained in:
commit
f53ccfbfeb
11
defaults/main.yml
Normal file
11
defaults/main.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
path: /srv/{{ role_name }}
|
||||||
|
|
||||||
|
storage_mount_override: {}
|
||||||
|
storage_mount_defaults:
|
||||||
|
type: "nfs4"
|
||||||
|
host: ""
|
||||||
|
host_path: ""
|
||||||
|
args: ""
|
||||||
|
dest_path: ""
|
||||||
|
user: ""
|
||||||
|
password: ""
|
||||||
8
handlers/main.yml
Normal file
8
handlers/main.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
- name: restart container
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ path }}"
|
||||||
|
project_name: "{{ role_name }}"
|
||||||
|
recreate: "always"
|
||||||
|
services: ["storage_mount"]
|
||||||
|
state: "restarted"
|
||||||
|
when: not _storage_mount_already_restarted
|
||||||
20
meta/main.yml
Normal file
20
meta/main.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: "Niklas Freese <niklas@urmel.de>"
|
||||||
|
description: storage_mount
|
||||||
|
company: "Urmel Services"
|
||||||
|
license: AGPL-3.0-or-later
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- role: traefik
|
||||||
41
tasks/main.yml
Normal file
41
tasks/main.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
- name: "set local variables from overrides and defaults"
|
||||||
|
set_fact:
|
||||||
|
storage_mount: "{{ (storage_mount_defaults | combine(storage_mount_override, recursive=True)) if storage_mount_override else storage_mount_defaults }}"
|
||||||
|
|
||||||
|
- name: get final escaped name
|
||||||
|
command: "systemd-escape --suffix=mount --path {{ storage_mount.dest_path }}"
|
||||||
|
register: escaped_mount_path
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: install nfs dependencies
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- nfs-common
|
||||||
|
|
||||||
|
- name: template nsf.service
|
||||||
|
template:
|
||||||
|
src: nfs.service.j2
|
||||||
|
dest: "/etc/systemd/system/{{ escaped_mount_path.stdout }}"
|
||||||
|
when:
|
||||||
|
- "'nfs' in storage_mount.type"
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: install cifs (for SMB) dependencies
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- cifs-utils
|
||||||
|
|
||||||
|
- name: template smb.service
|
||||||
|
template:
|
||||||
|
src: smb.service.j2
|
||||||
|
dest: "/etc/systemd/system/{{ escaped_mount_path.stdout }}"
|
||||||
|
when:
|
||||||
|
- "'cifs' in storage_mount.type"
|
||||||
|
|
||||||
|
- name: Ensure systemd mountpoint is enabled+started
|
||||||
|
systemd_service:
|
||||||
|
state: "started"
|
||||||
|
daemon_reload: true
|
||||||
|
enabled: true
|
||||||
|
name: "{{ escaped_mount_path.stdout }}"
|
||||||
13
templates/nfs.service.j2
Normal file
13
templates/nfs.service.j2
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Mount {{ storage_mount.dest_path }} via NFS
|
||||||
|
After = network-online.target
|
||||||
|
Wants = network-online.target
|
||||||
|
|
||||||
|
[Mount]
|
||||||
|
What={{ storage_mount.host }}:{{ storage_mount.host_path }}
|
||||||
|
Where={{ storage_mount.dest_path }}
|
||||||
|
Type={{ storage_mount.type }}
|
||||||
|
Options={{ storage_mount.args }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=graphical.target
|
||||||
13
templates/smb.service.j2
Normal file
13
templates/smb.service.j2
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Mount {{ storage_mount.dest_path }} via SMB
|
||||||
|
After = network-online.target
|
||||||
|
Wants = network-online.target
|
||||||
|
|
||||||
|
[Mount]
|
||||||
|
What=//{{ storage_mount.host }}/{{ storage_mount.host_path }}
|
||||||
|
Where={{ storage_mount.dest_path }}
|
||||||
|
Type={{ storage_mount.type }}
|
||||||
|
Options={{ storage_mount.args }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=graphical.target
|
||||||
Loading…
x
Reference in New Issue
Block a user