Skip to content

Commit

Permalink
DSOS-2749: add filesystems role (#725)
Browse files Browse the repository at this point in the history
* DSOS-2749: add role for managing filesystems

* tweaks

* updated readme
  • Loading branch information
drobinson-moj authored Apr 25, 2024
1 parent b2c3df9 commit 17ef823
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ansible/roles/filesystems/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Role for managing file shares

## Mount EFS file shares

In appropriate `group_vars`, e.g.

Multi-AZ:
```
filesystems_mount:
- dir: /test
fstype: nfs
opts: nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,nofail
src: "{{ ansible_ec2_placement_availability_zone }}.fs-0a170471eea499c2c.efs.eu-west-2.amazonaws.com:/"
```

Single-AZ, e.g. in eu-west-2a
```
filesystems_mount:
- dir: /test
fstype: nfs
opts: nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,nofail
src: "eu-west-2a.fs-0a170471eea499c2c.efs.eu-west-2.amazonaws.com:/"
```
16 changes: 16 additions & 0 deletions ansible/roles/filesystems/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Define list of filesystems to mount using `filesystems_mount` list.

# Example Multi-AZ EFS mount
#filesystems_mount:
# - dir: /test
# fstype: nfs
# opts: nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,nofail
# src: "{{ ansible_ec2_placement_availability_zone }}.fs-0a170471eea499c2c.efs.eu-west-2.amazonaws.com:/"

# Example Single-AZ EFS mount in eu-west-2a
#filesystems_mount:
# - dir: /test
# fstype: nfs
# opts: nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,nofail
# src: "eu-west-2a.fs-0a170471eea499c2c.efs.eu-west-2.amazonaws.com:/"
3 changes: 3 additions & 0 deletions ansible/roles/filesystems/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- role: get-ec2-facts
7 changes: 7 additions & 0 deletions ansible/roles/filesystems/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- import_tasks: mount.yml
tags:
- amibuild
- ec2provision
- ec2patch
when: filesystems_mount is defined
27 changes: 27 additions & 0 deletions ansible/roles/filesystems/tasks/mount.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Install packages
ansible.builtin.package:
name: "{{ item }}"
state: present
loop:
- nfs-utils
- cifs-utils

- name: Create mount point
ansible.builtin.file:
path: "{{ item.dir }}"
state: "directory"
loop_control:
label: "{{ item.dir }}"
loop: "{{ filesystems_mount }}"

- name: Mount filesystem
ansible.posix.mount:
fstype: "{{ item.fstype }}"
opts: "{{ item.opts | default('defaults,nofail') }}"
path: "{{ item.dir }}"
src: "{{ item.src }}"
state: "{{ item.state | default('mounted') }}"
loop_control:
label: "{{ item.dir }}"
loop: "{{ filesystems_mount }}"

0 comments on commit 17ef823

Please sign in to comment.