add mount-efs role
authorJustin Wind <j.wind@partner.samsung.com>
Fri, 8 Sep 2017 19:17:46 +0000 (12:17 -0700)
committerJustin Wind <j.wind@partner.samsung.com>
Fri, 8 Sep 2017 19:17:46 +0000 (12:17 -0700)
roles/mount-efs/defaults/main.yml [new file with mode: 0644]
roles/mount-efs/tasks/main.yml [new file with mode: 0644]

diff --git a/roles/mount-efs/defaults/main.yml b/roles/mount-efs/defaults/main.yml
new file mode 100644 (file)
index 0000000..c4d6604
--- /dev/null
@@ -0,0 +1,2 @@
+---
+efs_mount_path: /media/data
diff --git a/roles/mount-efs/tasks/main.yml b/roles/mount-efs/tasks/main.yml
new file mode 100644 (file)
index 0000000..788c496
--- /dev/null
@@ -0,0 +1,29 @@
+---
+- name: Install NFS tools
+  yum:
+    name: nfs-utils
+
+- name: Mount path
+  file:
+    path: "{{ efs_mount_path }}"
+    state: directory
+    owner: ec2-user
+    group: ec2-user
+    mode: "0755"
+
+- name: current AZ
+  check_mode: no
+  uri:
+    url: http://169.254.169.254/latest/meta-data/placement/availability-zone
+    return_content: yes
+  register: aws_current_az
+
+- name: Mount EFS volume
+  mount:
+    name: "{{ efs_mount_path }}"
+    src: "{{ efs_id }}.efs.{{ aws_current_az.content[:-1] }}.amazonaws.com:/"
+    fstype: nfs4
+    opts: "nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev"
+    passno: 0
+    dump: 0
+    state: mounted