Skip to content

Commit

Permalink
Merge pull request #4 from AcroMedia/add-support-for-aws-efs-access-p…
Browse files Browse the repository at this point in the history
…oints

Add support for aws efs access points
  • Loading branch information
dale-c-anderson authored Mar 17, 2023
2 parents 7e7a659 + 165401e commit d28d016
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ nfs_secondary_groups:
nfs_client_share_mount_point: "{{ nfs_share_dir }}"
nfs_host: 10.0.0.50
```
@TODO: Create Drupal example with public, private, temp mount points on Ec2
@TODO: Create Drupal example with public, private, temp mount points on EFS With Access Points
11 changes: 10 additions & 1 deletion client/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@ nfs_client_remote_export: "{{ nfs_client_share_mount_point }}"
nfs_client_install_software: true
nfs_client_create_fstab_entry: true
nfs_client_mount_opts: 'auto,noatime,nolock,bg,nfsvers=4,intr,tcp,actimeo=1800'
# for AWS EFS, use:
nfs_client_mount_fstype: nfs
nfs_client_mount_src: "{{ nfs_host }}:{{ nfs_client_remote_export }}"
nfs_client_efsutils_src_dir: /usr/local/src/aws-efs-utils # Where to download and keep the build source

# For AWS EFS with a single mount point, use:
# nfs_client_mount_opts: 'nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport'

# For AWS EFS with one or more EFS Access Points, use:
# nfs_client_mount_opts: '_netdev,tls,accesspoint={{ efs_access_point_id }}'
# nfs_client_mount_fstype: efs # <<<<<<< Won't work unless amazon-efs-utils has been installed
# nfs_client_mount_src: "{{ efs_filesystem_id }}"
29 changes: 29 additions & 0 deletions client/tasks/Debian.amazon-efs-utils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Install efs tool build prerequisites
apt:
name:
- git
- binutils
state: present

- name: Download efs-utils
git:
repo: https://github.com/aws/efs-utils
dest: "{{ nfs_client_efsutils_src_dir }}"
update: no

- name: Build efs-utils
shell: "{{ nfs_client_efsutils_src_dir }}/build-deb.sh"
args:
chdir: "{{ nfs_client_efsutils_src_dir }}"
creates: "{{ nfs_client_efsutils_src_dir }}/build/debbuild/amazon-efs-utils*deb"

- name: Locate newly built deb package with find, as it will have a version number in it
shell: >
find {{ nfs_client_efsutils_src_dir }}/build/debbuild -name 'amazon-efs-utils-*.deb' -print -quit
register: efs_utils_find_result

- name: Install the amazon-efs-utils deb package
apt:
deb: "{{ efs_utils_find_result.stdout }}"
state: present
12 changes: 8 additions & 4 deletions client/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
loop_control:
loop_var: version_specific_vars_file

- name: Install packages
- name: Install nfs client packages
include_tasks: "tasks/{{ ansible_os_family }}.yml"

- name: Build and install amazon-efs-utils
include_tasks: "tasks/{{ ansible_os_family }}.amazon-efs-utils.yml"
when: nfs_client_mount_fstype == 'efs'

- name: Check if mount point exists for NFS client
stat:
path: "{{ nfs_client_share_mount_point }}"
Expand All @@ -21,9 +25,9 @@

- name: Create fstab entry for NFS client
mount:
name: "{{ nfs_client_share_mount_point }}"
src: "{{ nfs_host }}:{{ nfs_client_remote_export }}"
fstype: nfs
path: "{{ nfs_client_share_mount_point }}" # Which local folder on the machine does the remote share get mounted to? Used to be called 'name' or 'dest'.
src: "{{ nfs_client_mount_src }}"
fstype: "{{ nfs_client_mount_fstype }}"
opts: "{{ nfs_client_mount_opts }}"
state: mounted
when: nfs_client_create_fstab_entry == true
Expand Down

0 comments on commit d28d016

Please sign in to comment.