Skip to content

Commit

Permalink
Merge pull request #237 from lemberg/issue/233-invalid-nfs-exports
Browse files Browse the repository at this point in the history
Avoid creating an invalid NFS exports file
  • Loading branch information
T2L committed Jan 27, 2021
2 parents 26ca0c6 + d7a3822 commit 456293b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Updates:

Fixes:

- [GH-233](https://github.com/lemberg/draft-environment/issues/233) - Fix invalid NFS exports file produced under certain circumstances
- [GH-234](https://github.com/lemberg/draft-environment/issues/234) - Fix broken PiP installation by updating Python within the VM to version 3.7
- [GH-223](https://github.com/lemberg/draft-environment/issues/223) - Ensure that Python 3 is default in the VM
- [GH-218](https://github.com/lemberg/draft-environment/issues/218) - Address newly introduced PHPCS errors/warnings
Expand Down
27 changes: 19 additions & 8 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Configure synched folders.
config.vm.synced_folder configuration.get("vagrant.source_directory"), configuration.get("vagrant.destination_directory"), configuration.get("vagrant.synced_folder_options")

config.vm.synced_folder ".", "/vagrant", id: "vagrant", type: "nfs", create: true

# Provisioning
#
# See https://docs.vagrantup.com/v2/provisioning/index.html

# Get correct path to the Ansible playbook within the machine.
require 'pathname'
project_pathname = Pathname.new PROJECT_BASE_PATH
vm_pathname = Pathname.new VM_BASE_PATH

# Ensure Python 3.x is set as a default.
config.vm.provision "shell",
keep_color: true,
Expand All @@ -226,12 +219,30 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "file", source: configuration.get("mkcert.directory") + "/.", destination: "/tmp/mkcert"
end

# Get correct path to the Ansible playbook within the machine (avoiding the
# invalid NFS exports file at the same time).
require 'pathname'

source_pathname = (Pathname.new configuration.get("vagrant.source_directory")).realpath
vm_pathname = (Pathname.new VM_BASE_PATH).realpath

# If draft environment is within the synced folder, construct correct path
# to the provisioning directory within the destination directory.
if File.fnmatch(source_pathname.to_path + "/*", vm_pathname.to_path)
ansible_provisioning_path = File.join(configuration.get("vagrant.destination_directory"), vm_pathname.relative_path_from(source_pathname), "provisioning")
# Else draft environment is not within the synced folder. In this case create
# another NFS synced folder containing the required files.
else
config.vm.synced_folder VM_BASE_PATH, "/vagrant", id: "vagrant", type: "nfs", create: true
ansible_provisioning_path = "/vagrant/provisioning"
end

# Run Ansible provisioner from within the virtual machine using Ansible Local
# provisioner.
config.vm.provision "ansible_local" do |ansible|
ansible.become = true
ansible.playbook = "playbook.yml"
ansible.provisioning_path = File.join("/vagrant", vm_pathname.relative_path_from(project_pathname), "/provisioning")
ansible.provisioning_path = ansible_provisioning_path
ansible.extra_vars = configuration.getConfiguration()
ansible.galaxy_role_file = "requirements.yml"
ansible.galaxy_roles_path = "/etc/ansible/roles"
Expand Down

0 comments on commit 456293b

Please sign in to comment.