Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrant: Support DHCP #892

Merged
merged 1 commit into from
Sep 18, 2017
Merged

Vagrant: Support DHCP #892

merged 1 commit into from
Sep 18, 2017

Conversation

tangrufus
Copy link
Member

Allow running multiple Trellis machines at the same time.

Tested with 2 DHCP machines and 1 static IP machine running at the same time. Results:

$ cat /etc/exports
# VAGRANT-BEGIN: 501 78f3bfb6-4ae0-4305-b4a3-8cd68040aa6b
"/Users/me/Code/siteA/bedrock" 172.28.128.3 -alldirs -mapall=501:20
"/Users/me/Code/siteA/trellis" 172.28.128.3 -alldirs -mapall=501:20
# VAGRANT-END: 501 78f3bfb6-4ae0-4305-b4a3-8cd68040aa6b
# VAGRANT-BEGIN: 501 2bf7c671-523e-4ca5-9a81-e85797428609
"/Users/me/Code/siteB/bedrock" 172.28.128.4 -alldirs -mapall=501:20
"/Users/me/Code/siteB/trellis" 172.28.128.4 -alldirs -mapall=501:20
# VAGRANT-END: 501 2bf7c671-523e-4ca5-9a81-e85797428609
# VAGRANT-BEGIN: 501 8dafbb55-1263-4829-90e2-b76fb68323c0
"/Users/me/Code/siteC/site" 192.168.50.5 -alldirs -mapall=501:20
"/Users/me/Code/siteC/trellis" 192.168.50.5 -alldirs -mapall=501:20
# VAGRANT-END: 501 8dafbb55-1263-4829-90e2-b76fb68323c0

$ cat /etc/hosts
...
## vagrant-hostmanager-start id: 95b74937-d48d-468e-850a-ce2664ad1ea7
172.28.128.3	www.typist.dev
172.28.128.3	typist.dev
## vagrant-hostmanager-end

## vagrant-hostmanager-start id: 3fa4d5c6-050d-4545-bc5c-e4db40ec516c
172.28.128.4	ww2.typist.dev
172.28.128.4	ww3.typist.dev
## vagrant-hostmanager-end

## vagrant-hostmanager-start id: 5695f53b-c08e-46be-9d1f-dd08d9cc2842
192.168.50.5	example.dev
192.168.50.5	www.example.dev
## vagrant-hostmanager-end

The ip_resolver proc is taken from devopsgroup-io/vagrant-hostmanager#86 (comment)
Related #295 (comment)
Closes #873

Copy link
Member

@swalkinshaw swalkinshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we'll probably merge this since it's fairly simple and optional.

Vagrantfile Outdated
config.vm.network :private_network, type: 'dhcp', hostsupdater: 'skip'

cached_addresses = {}
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but prefix resolving_vm with _ since it's unused

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@swalkinshaw
Copy link
Member

We may even want to make dhcp the default. Seems simpler?

@tangrufus
Copy link
Member Author

👍 for default

However, if you already have a VM with static IP (running / poweroff doesn't matter), you need $ vagrant destroy before switching to DHCP.

@tangrufus tangrufus deleted the dhcp branch September 18, 2017 19:27
@swalkinshaw
Copy link
Member

I think just vagrant reload works?

@tangrufus
Copy link
Member Author

I had trouble with vagrant reload.
But, it could cause by vagrant-triggers, didn't investigate.

@oxyc
Copy link

oxyc commented Sep 22, 2017

I had trouble with vagrant reload.

I tested this over at Drupal VM and same happened for me if you're referring to a mount.nfs: access denied by server while mounting ... error @tangrufus? vagrant halt; vagrant up fixed it though.

@tangrufus
Copy link
Member Author

I got more errors besides mount.nfs: access denied by server while mounting .... I guess they were from one of my vagrant plugins.

Just curious: Do you work while travelling, @oxyc? I found it extremely hard to stay in front of the computer when everyone else in the hostel went out for sun and beach.

@oxyc
Copy link

oxyc commented Sep 24, 2017

For reference the plugins I had were vagrant-vbguest and vagrant-hostmanager. Guess it might be triggers.

@tangrufus Nah I never liked mixing work and travel, wouldn't do either at full capacity. I usually travel 4-6 months until I get sick of it, then find a place to work for 6-8 months until I miss it again, and repeat. Also I like signing off so I don't want to bring my laptop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Trellis Projects at once
3 participants