Reputation: 7634
I'm trying to mount an AWS EFS filesystem on Windows Server 2019, using NFS, and configuring it with Ansible.
I was already able to mount the same AWS EFS filesystem on a Linux instance in the same Region, VPC and Availibility Zone, which makes me think that the AWS EFS part is OK.
This is what I have to configure NFS on the Windows instance:
---
- name: Ensure NFS is installed.
win_feature:
name: "{{ nfs_package }}"
state: present
- name: Add registry key AnonymousGID
win_regedit:
path: HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default
name: AnonymousGID
value: 0
type: dword
- name: Add registry key AnonymousUID
win_regedit:
path: HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default
name: AnonymousUID
value: 0
type: dword
- name: Copy BAT file
win_copy:
src: nfs_mount_script.bat
dest: C:\nfs_mount_script.bat
- name: Create scheduled task which will mount the network drive
win_scheduled_task:
name: nfs_mount
description: Map NFS share so that it is visible for Ansible tasks
actions:
- path: C:\nfs_mount_script.bat
triggers:
- type: boot
username: SYSTEM
run_level: highest
- name: Mount an NFS volume
win_command: C:\nfs_mount_script.bat
This is nfs_mount_script.bat
:
mount -o anon fs-0123456789abcdef.efs.eu-central-1.amazonaws.com:/ J:
This is the error in my console output:
amazon-ebs: TASK [foo.jenkins-node.windows : Ensure NFS is installed.] *******************[0m
amazon-ebs: Friday 28 May 2021 21:18:10 +0200 (0:00:00.023) 0:00:56.326 ************[0m
amazon-ebs: changed: [default][0m
amazon-ebs:[0m
amazon-ebs: TASK [foo.jenkins-node.windows : Add registry key AnonymousGID] **************[0m
amazon-ebs: Friday 28 May 2021 21:19:23 +0200 (0:01:12.874) 0:02:09.201 ************[0m
amazon-ebs: changed: [default][0m
amazon-ebs:[0m
amazon-ebs: TASK [foo.jenkins-node.windows : Add registry key AnonymousUID] **************[0m
amazon-ebs: Friday 28 May 2021 21:19:25 +0200 (0:00:01.963) 0:02:11.164 ************[0m
amazon-ebs: ok: [default][0m
amazon-ebs:[0m
amazon-ebs: TASK [foo.jenkins-node.windows : Copy BAT file] ******************************[0m
amazon-ebs: Friday 28 May 2021 21:19:27 +0200 (0:00:01.913) 0:02:13.077 ************[0m
amazon-ebs: changed: [default][0m
amazon-ebs:[0m
amazon-ebs: TASK [foo.jenkins-node.windows : Create scheduled task which will mount the network drive] ***[0m
amazon-ebs: Friday 28 May 2021 21:19:31 +0200 (0:00:03.667) 0:02:16.745 ************[0m
amazon-ebs: changed: [default][0m
amazon-ebs:[0m
amazon-ebs: TASK [foo.jenkins-node.windows : Mount an NFS volume] ************************[0m
amazon-ebs: Friday 28 May 2021 21:19:33 +0200 (0:00:02.482) 0:02:19.227 ************[0m
amazon-ebs: fatal: [default]: FAILED! => changed=true[0m
amazon-ebs: cmd: C:\nfs_mount_script.bat[0m
amazon-ebs: delta: '0:00:47.121981'[0m
amazon-ebs: end: '2021-05-28 07:20:22.253220'[0m
amazon-ebs: msg: non-zero return code[0m
amazon-ebs: rc: 1[0m
amazon-ebs: start: '2021-05-28 07:19:35.131239'[0m
amazon-ebs: stderr: ''[0m
amazon-ebs: stderr_lines: <omitted>[0m
amazon-ebs: stdout: |2-[0m
amazon-ebs:[0m
amazon-ebs: C:\Users\Administrator>mount -o anon fs-0123456789abcdef.efs.eu-central-1.amazonaws.com:/ J:[0m
amazon-ebs: Network Error - 53[0m
amazon-ebs:[0m
amazon-ebs: Type 'NET HELPMSG 53' for more information.[0m
amazon-ebs: stdout_lines: <omitted>[0m
Already tried:
NET HELPMSG 53
- not very helpful or I wouldn't ask here.mount -o anon fs-0123456789abcdef.efs.eu-central-1.amazonaws.com:/ J:
with mount -o anon \\fs-03614eb713a56f8c2.efs.eu-central-1.amazonaws.com\ J:
- neither of the two work.For reference, this is the corresponding Ansible code on a Linux (Ubuntu) instance, where it does work:
---
- name: Ensure NFS is installed.
package:
name: "{{ nfs_package }}"
state: present
- name: Create a mountable directory if it does not exist
file:
path: "{{ efs_mount_dir }}"
state: directory
owner: "{{ jenkins_user }}"
group: "{{ jenkins_user }}"
mode: '0775'
- name: Mount an NFS volume
mount:
name: "{{ efs_mount_dir }}"
src: "{{ efs_file_system_id }}.efs.{{ aws_region }}.amazonaws.com:/"
fstype: nfs4
opts: nfsvers=4.1
state: mounted
What are the magic Ansible incantations that I need to copy/paste into my YAML file so that the Windows Server will mount the EFS filesystem?
Upvotes: 1
Views: 4217
Reputation: 11
The Microsoft supplied NFS client in Windows Server 2022 (and below) only support NFSv3. EFS requires NFSv4 or NFS4.1 so the MS client is not going to work. (note that Windows NFS server uses NFSv4)
If you want a commercially supported client, OpenText sells a client that works (it does require a little registry work). https://www.opentext.com/products-and-solutions/products/specialty-technologies/connectivity/nfs-client-nfs-solo
Other options, free but dated and take more effort/maintenance on your side: http://citi.umich.edu/projects/nfsv4/windows/ https://github.com/contentfree/ms-nfs41-client
Upvotes: 1
Reputation: 4710
Amazon EFS is not supported on Windows instances.
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/AmazonEFS.html
Upvotes: 0