Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSOS-2749: add filesystems role #725

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}"
Loading