Skip to content

Commit 6a6c385

Browse files
authored
feat: Add mount role (#17)
1 parent 50032a4 commit 6a6c385

File tree

6 files changed

+127
-0
lines changed

6 files changed

+127
-0
lines changed

roles/mount/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# mount
2+
3+
Ansible role for configuring and mounting local filesystems.
4+
5+
## Requirements
6+
7+
None.
8+
9+
## Dependencies
10+
11+
None.
12+
13+
## Role Variables
14+
15+
Refer to [defaults/main.yml](defaults/main.yml) for a list of variables along with documentation.
16+
17+
## Example Playbook
18+
19+
```yaml
20+
- hosts: all
21+
roles:
22+
- role: hostinger.common.mount
23+
```
24+
25+
## License
26+
27+
See [LICENSE](../../LICENSE)

roles/mount/defaults/main.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
mount_default_mode: "0750"
3+
mount_default_owner: root
4+
mount_default_group: root
5+
mount_mountpoints: []
6+
# mount_mountpoints:
7+
# - path: /home/example
8+
# src: /dev/sda1
9+
# fstype: ext4
10+
# fsopts: ""
11+
# opts: defaults
12+
# boot: true
13+
# mode: "0755"
14+
# state: mounted
15+
# passno: 2
16+
# backup: true
17+
# fstab: ""
18+
# owner: root
19+
# group: root
20+
# dump: 0

roles/mount/meta/main.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
galaxy_info:
3+
role_name: mount
4+
author: hostinger
5+
description: Ansible role for configuring and mounting local filesystems.
6+
license: license (MIT)
7+
min_ansible_version: "2.10"
8+
platforms:
9+
- name: Fedora
10+
versions:
11+
- all
12+
- name: Debian
13+
versions:
14+
- all
15+
- name: Ubuntu
16+
versions:
17+
- all
18+
galaxy_tags:
19+
- mount
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Converge
3+
hosts:
4+
- all
5+
6+
roles:
7+
- mount
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
driver:
5+
name: docker
6+
platforms:
7+
- name: default
8+
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest
9+
volumes:
10+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
11+
command: ${MOLECULE_DOCKER_COMMAND:-""}
12+
cgroupns_mode: host
13+
pre_build_image: true
14+
privileged: true
15+
platform: amd64
16+
provisioner:
17+
name: ansible
18+
playbooks:
19+
converge: ${MOLECULE_PLAYBOOK:-converge.yml}

roles/mount/tasks/main.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
- name: Create mountpoints
3+
ansible.builtin.file:
4+
path: "{{ item.path }}"
5+
state: directory
6+
mode: "{{ item.mode | default(mount_default_mode) }}"
7+
owner: "{{ item.owner | default(mount_default_owner) }}"
8+
group: "{{ item.group | default(mount_default_group) }}"
9+
with_items:
10+
- "{{ mount_mountpoints }}"
11+
when:
12+
- item.fstype != "swap"
13+
14+
- name: Create file systems
15+
community.general.filesystem:
16+
device: "{{ item.src }}"
17+
type: "{{ item.fstype }}"
18+
opts: "{{ item.fsopts | default(omit) }}"
19+
with_items:
20+
- "{{ mount_mountpoints }}"
21+
22+
- name: Mount mountpoints
23+
ansible.posix.mount:
24+
path: "{{ item.path }}"
25+
backup: "{{ item.backup | default(omit) }}"
26+
boot: "{{ item.boot | default(omit) }}"
27+
dump: "{{ item.dump | default(omit) }}"
28+
fstab: "{{ item.fstab | default(omit) }}"
29+
fstype: "{{ item.fstype | default(omit) }}"
30+
opts: "{{ item.opts | default(omit) }}"
31+
passno: "{{ item.passno | default(omit) }}"
32+
src: "{{ item.src | default(omit) }}"
33+
state: "{{ item.state | default('mounted') }}"
34+
with_items:
35+
- "{{ mount_mountpoints }}"

0 commit comments

Comments
 (0)