Skip to content

Commit

Permalink
Merge pull request geerlingguy#2162 from oxyc/vagrant-fix-nfs
Browse files Browse the repository at this point in the history
Issue geerlingguy#2154: Add vagrant-nfs-fix role to fix NFS timeout issues on macOS
  • Loading branch information
geerlingguy authored May 8, 2021
2 parents 0c3af7d + fda7c96 commit 20b7654
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 0 deletions.
4 changes: 4 additions & 0 deletions default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ vagrant_plugins:
- name: vagrant-vbguest
- name: vagrant-hostsupdater

# Automatically fix timeout issues with NFS on macOS. See
# https://github.com/geerlingguy/drupal-vm/issues/2154
vagrant_nfs_fix_enabled: false

ansible_python_interpreter: python3

# Minimum required versions.
Expand Down
4 changes: 4 additions & 0 deletions docs/getting-started/installation-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Please read through the [Quick Start Guide](https://github.com/geerlingguy/drupa
<iframe width="560" height="315" src="https://www.youtube.com/embed/PR9uh_GGZhI" frameborder="0" allowfullscreen></iframe>

_In this quick overview, Jeff Geerling will show you where you can learn more about Drupal VM, then show you a simple Drupal VM setup._

## NFS Timeout on Big Sur

If you are using NFS shares on macOS Big Sur, and you have problems with the NFS mount going away, please set `vagrant_nfs_fix_enabled: true` in your `config.yml`.
1 change: 1 addition & 0 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- { role: geerlingguy.repo-epel, when: ansible_os_family == 'RedHat' }
- { role: geerlingguy.repo-remi, when: ansible_os_family == 'RedHat', tags: ['webserver', 'php'] }
- { role: drupalvm.hostname, when: hostname_configure }
- { role: drupalvm.vagrant-nfs-fix, when: vagrant_nfs_fix_enabled }
- { role: geerlingguy.firewall, when: firewall_enabled }
- { role: geerlingguy.git }
- { role: geerlingguy.postfix }
Expand Down
29 changes: 29 additions & 0 deletions provisioning/roles/drupalvm.vagrant-nfs-fix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Drupal VM Vagrant NFS Fix Role

This role exists to fix [issue #2154](https://github.com/geerlingguy/drupal-vm/issues/2154).

## Requirements

This role is meant to be run in Drupal VM.

## Role Variables

Available variables are listed below:

```yaml
vagrant_nfs_fix_keepalive_file: "/vagrant/.vagrant-nfs-fix-keepalive.tmp"
```
Path to the keepalive file that we'll be `touch`ed every 30 seconds to keep NFS from timing out.

## Dependencies

None.

## License

MIT / BSD

## Author Information

This role was created in 2021 by [Oskar Schöldström](http://oxy.fi) and [Jeff Geerling](https://www.jeffgeerling.com/) (author of [Ansible for DevOps](https://www.ansiblefordevops.com/)).
2 changes: 2 additions & 0 deletions provisioning/roles/drupalvm.vagrant-nfs-fix/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
vagrant_nfs_fix_keepalive_file: "/vagrant/.vagrant-nfs-fix-keepalive.tmp"
22 changes: 22 additions & 0 deletions provisioning/roles/drupalvm.vagrant-nfs-fix/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Copy Vagrant NFS fix script into place.
template:
src: vagrant-nfs-fix.j2
dest: /usr/sbin/vagrant-nfs-fix
owner: root
group: root
mode: 0755

- name: Copy Vagrant NFS fix systemd unit file into place.
template:
src: vagrant-nfs-fix.unit.j2
dest: /etc/systemd/system/vagrant-nfs-fix.service
owner: root
group: root
mode: 0644

- name: Configure the NFS fix service.
service:
name: vagrant-nfs-fix
state: started
enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

while true; do
touch {{ vagrant_nfs_fix_keepalive_file }}
sleep 1
rm {{ vagrant_nfs_fix_keepalive_file }}
sleep 30
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Workaround for vagrant NFS inactivity bug
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/sbin/vagrant-nfs-fix

[Install]
WantedBy=multi-user.target

0 comments on commit 20b7654

Please sign in to comment.