forked from geerlingguy/drupal-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue geerlingguy#2154: Add vagrant-nfs-fix role to fix NFS timeout i…
…ssues on macOS Co-authored-by: MokDevelopment Co-authored-by: Susanne Coates <[email protected]>
- Loading branch information
Showing
8 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
2
provisioning/roles/drupalvm.vagrant-nfs-fix/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
32 changes: 32 additions & 0 deletions
32
provisioning/roles/drupalvm.vagrant-nfs-fix/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
- 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 init script into place. | ||
template: | ||
src: vagrant-nfs-fix.init.j2 | ||
dest: /etc/init.d/vagrant-nfs-fix | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
when: ansible_service_mgr != 'systemd' | ||
|
||
- name: Copy Vagrant NFS fix systemd unit file into place (for systemd systems). | ||
template: | ||
src: vagrant-nfs-fix.unit.j2 | ||
dest: /etc/systemd/system/vagrant-nfs-fix.service | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
when: ansible_service_mgr == 'systemd' | ||
|
||
- name: Configure the NFS fix service. | ||
service: | ||
name: vagrant-nfs-fix | ||
state: started | ||
enabled: true |
55 changes: 55 additions & 0 deletions
55
provisioning/roles/drupalvm.vagrant-nfs-fix/templates/vagrant-nfs-fix.init.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#! /bin/sh | ||
# /etc/init.d/vagrant-nfs-fix | ||
|
||
### BEGIN INIT INFO | ||
# Provides: vagrant-nfs-fix | ||
# Required-Start: $local_fs $network | ||
# Required-Stop: $local_fs | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: Start vagrant-nfs-fix at boot time | ||
# Description: Continuously touch a file within an NFS mount to avoid timeout problems on macOS. | ||
### END INIT INFO | ||
|
||
PID_FILE="/var/run/vagrant-nfs-fix.pid" | ||
|
||
# Carry out specific functions when asked to by the system | ||
case "$1" in | ||
start) | ||
echo "Starting vagrant-nfs-fix." | ||
/usr/sbin/vagrant-nfs-fix & | ||
echo $! > $PID_FILE | ||
;; | ||
stop) | ||
echo "Stopping vagrant-nfs-fix." | ||
kill `cat $PID_FILE` | ||
rm $PID_FILE | ||
;; | ||
restart) | ||
echo "Restarting firewall." | ||
kill `cat $PID_FILE` | ||
rm $PID_FILE | ||
|
||
/usr/sbin/vagrant-nfs-fix & | ||
echo $! > $PID_FILE | ||
;; | ||
status) | ||
EXIT=4 # program or service status is unknown | ||
if [ -e $PID_FILE ]; then | ||
if ps -p `cat $PID_FILE` > /dev/null 2>&1; then | ||
EXIT=0 # program is running or service is OK | ||
else | ||
EXIT=3 # program is not running | ||
fi | ||
else | ||
EXIT=3 # program is not running | ||
fi | ||
exit $EXIT | ||
;; | ||
*) | ||
echo "Usage: /etc/init.d/vagrant-nfs-fix {start|stop|status|restart}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
6 changes: 6 additions & 0 deletions
6
provisioning/roles/drupalvm.vagrant-nfs-fix/templates/vagrant-nfs-fix.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
while true; do | ||
touch {{ vagrant_nfs_fix_keepalive_file }} | ||
sleep 30 | ||
done |
12 changes: 12 additions & 0 deletions
12
provisioning/roles/drupalvm.vagrant-nfs-fix/templates/vagrant-nfs-fix.unit.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |