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

DNS management should be done with a modified vagrant-hostmanager instead of Puppet #68

Closed
purpleidea opened this issue Mar 29, 2015 · 7 comments

Comments

@purpleidea
Copy link
Owner

Currently /etc/hosts is managed with puppet and the shell provider because it was an easy hack to setup when this tool was first written.

Since omv has become more generally useful, we should patch it so that puppet isn't required in the base image. This is needed to support images without puppet such as atomic.

Some patches were needed for vagrant-hostmanager:

https://github.com/purpleidea/vagrant-hostmanager

They need to be tested and cleaned up (available in feat branches)'

Omv then needs to add this feature. Also available in a feature branch.

If you want to work on this, please ping me, and I'll make sure my latest testing version is online.

Cheers!

@cgwalters
Copy link

I was able to do this with this Ansible code:

---
- hosts: all
  sudo: yes
  tasks:
    - name: "Build hosts file"
      lineinfile: dest=/etc/hosts
                  regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}"
                  state=present
      when: hostvars[item].ansible_default_ipv4.address is defined
      with_items: groups['all']

@purpleidea
Copy link
Owner Author

@cgwalters Sweet... Actually oh-my-vagrant has ansible support although there might be at least one bug so it needs love / testing. This feature could be plugged in this way though.

Note, the configuration is to set the "second" (static) network which doesn't exist initially, where as this I think is using the default IP's.

I feel this should probably be done without ansible though to remove this dependency and so that when you're monkeying with ansible this stays out of the way, but that's just my opinion, and I would gladly accept patches to do it this way if someone so wishes.

@purpleidea
Copy link
Owner Author

I've written and tested this and it is now available in a feature branch: https://github.com/purpleidea/oh-my-vagrant/tree/feat/hostmanager

The one catch is that it needs a modified vagrant-hostmanager. Those patches are available in: https://github.com/purpleidea/vagrant-hostmanager/tree/feat/extras

That has been sent "upstream" as this PR: devopsgroup-io/vagrant-hostmanager#145

If there are any issues, I would appreciate help in getting them fixed.

The +ive note, is that I tested this, and with my patches and this feature branch, DNS seems to work great! If someone would like the ability to do this with ansible instead of hostmanager, I'd happily accept that patch too, and make it configurable.

@goern
Copy link
Contributor

goern commented Apr 17, 2015

build vagrant-hostmanager+feat/extras and it seems to work for me.

using oh-my-vagrant+feat/hostmanager seems to work to, I up'd, destroy'd a few machine. The only thing that is confusing me is that there is a host that is not managed by OMV:

[goern@rh-t540p-goern-example-com vagrant (feat/hostmanager)]$ vagrant status
Current machine states:

developer                 running (libvirt)
atomichost                running (libvirt)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
[goern@rh-t540p-goern-example-com vagrant (feat/hostmanager)]$ vssh developer
Last login: Fri Apr 17 08:49:35 2015 from 192.168.121.1
[vagrant@developer ~]$ cat /etc/hosts
::1 localhost   localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

## vagrant-hostmanager-start
192.168.123.100 developer.example.com   developer
192.168.123.101 atomichost.example.com  atomichost
192.168.123.3   ose3onah.example.com    ose3onah
## vagrant-hostmanager-end
[vagrant@developer ~]$ 

Even changing the domain in omv.yaml and vagrant hostmanager works!

@purpleidea
Copy link
Owner Author

@goern

I'm guessing you're referring to:

192.168.123.3   ose3onah.example.com    ose3onah

and wondering what that is?

In addition to the host names of all available machines, it also creates on extra entry with that IP, and the hostname == omv-namespace.

So your namespace is probably: ose3onah

This last entry is used as a VIP when needed by certain applications.

Make sense?
Thanks for testing!
This all needs better documentation, sorry :(

@purpleidea
Copy link
Owner Author

If devopsgroup-io/vagrant-hostmanager#145 isn't merged soon, who wants to fork (for now) and put a new version of this project on rubygems? We can name it vagrant-hm2.

Alternatively, we could distribute a tiny shell script with omv that "live" patches the ~/.vagrant.d/gems/gems/vagrant-hostmanager directory in an idempotent way. Yuck, but doable.

In parallel, who can package this for Fedora, including my patch so that it's part of the existing vagrant+vagrant-libvirt RPM's. @goern <-- want to follow up on this?

@purpleidea
Copy link
Owner Author

Since the DNS hostmanager patches are in git master, I'm going to close this.
You need to install vagrant-hostmanager, as a dependency, and patch it. To do so, you can use this script: https://github.com/purpleidea/oh-my-vagrant/blob/master/extras/patch-hostmanager.sh

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

No branches or pull requests

3 participants