Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #401 from oxyc/patch-1
Browse files Browse the repository at this point in the history
Add support for sourcing a local Vagrantfile
  • Loading branch information
geerlingguy committed Jan 29, 2016
2 parents c1fa34e + 972e60f commit bb9ba95
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vagrant_ansible_inventory_default
config.yml
drupal.make.yml
Vagrantfile.local
examples/prod/inventory
scripts/
roles/
5 changes: 5 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Set the name of the VM. See: http://stackoverflow.com/a/17864388/100134
config.vm.define vconfig['vagrant_machine_name'] do |d|
end

# Allow an untracked Vagrantfile to modify the configurations
if File.exist?('Vagrantfile.local')
eval File.read 'Vagrantfile.local'
end
end
55 changes: 55 additions & 0 deletions docs/other/local-vagrantfile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Out of the box Drupal VM supports having VirtualBox, Parallels as well as VMware as a provider. Besides these there are multitude of others available (for example `vagrant-aws`, `vagrant-digitalocean`).

If you want to use an unsupported provider, or otherwise modify the vagrant configuration in a way that is not exposed by Drupal VM, you can create a `Vagrantfile.local` in the root directory of this project.

The file will be sourced at the end of the `Vagrant.configure` block so you will have access to Vagrant's `config.vm` object as well as the contents of the `config.yml` file within the `vconfig` hash.

To add a configuration just create a `Vagrantfile.local` in the root like so:

```ruby
config.vm.provider :virtualbox do |v|
# Enable GUI mode instead of running a headless machine.
v.gui = true

# Reduce disk usage of multiple boxes by sharing a master VM.
v.linked_clone = true

# Cap the host CPU execution at 50% usage.
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
end
```

## Example: Using the `vagrant-aws` provider

Add the following variables to your `config.yml`.

```yaml
aws_keypair_name: 'keypair'
aws_ami: 'ami-7747d01e'
aws_tags_name: 'Drupal VM'
aws_ssh_username: 'ubuntu'
aws_ssh_private_key: '~/.ssh/aws.pem'
```
Create a `Vagrantfile.local` in the root directory of your project.

```ruby
config.vm.provider :aws do |aws, override|
override.nfs.functional = false
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.keypair_name = vconfig['aws_keypair_name']
aws.tags['Name'] = vconfig['aws_tags_name']
aws.ami = vconfig['aws_ami']
override.ssh.username = vconfig['aws_ssh_username']
override.ssh.private_key_path = vconfig['aws_ssh_private_key']
end
```

Add the `AWS_ACCESS_KEY_ID` and the `AWS_SECRET_ACCESS_KEY` environment variables to your shell.

Then run `vagrant up --provider=aws` to provision the instance.

_For additional configuring options read the [Vagrant AWS Provider's README](https://github.com/mitchellh/vagrant-aws#readme)_
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pages:
- Other Information:
- 'Using Different Base OSes': 'other/base-os.md'
- 'Using Different Webservers': 'other/webservers.md'
- 'Using a local Vagrantfile': 'other/local-vagrantfile.md'
- 'PHP 7 on Drupal VM': 'other/php-7.md'
- 'Networking Notes': 'other/networking.md'
- 'Drupal 6 Notes': 'other/drupal-6.md'
Expand Down

0 comments on commit bb9ba95

Please sign in to comment.