-
Notifications
You must be signed in to change notification settings - Fork 25
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
enable configuring the machine's hostname #14
Conversation
This enables a vagrant user to create a more realistic test environment if they use the name of their hosts in the inventory file (e.g. if they use the inventory file to create bind9 config)
👍 Patch works great for me. |
Is there any reason not to use @mavimo : As far as tried, and regarding testing "real life" playbooks, it doesn't help for group_vars & host_vars since the Temp inventory is in
for this to work, assuming Otherwise, it's pretty cool ! |
Leucos: Honestly, no reason beyond me not realizing that was easily doable -- I would agree that using existing Vagrant metadata that on the surface seems to mean the same thing would probably be better than my solution (does it mean the same thing?). I wrote this patch as a quick fix for testing a bind9 playbook that translates the inventory to zone files and this fix satisfied those needs. Honestly, I think a better approach to creating the temporary inventory file would be to read the existing hosts file and output a new one with just a targeted group overwritten by the config present in vagrant (either to /tmp or in the same directory etc) -- leaving var sections and other groups intact. |
It could be nice to hear @dsander 's opinion on these topics. |
@leucos some example: ---
- hosts: webserver
vars_files:
- [ "vars/${inventory_hostname}/apache2.yml", "vars/apache2.yml" ]
handlers:
- include: handlers/apache2.yml
tasks:
- include: handlers/apache2.yml this require to have a inventory_hostname set to a valid value (eg foo.bar.com) and having a inventory_hostname that maatch the production domain make possible to reproduce it with right settings. |
@mavimo agreed. However, since temporary inventory is create in Here's my attempt, just in case you want to try : I can run real life playbooks without modifications. Note : of course network related things (e.g. firewall rules) and user authorization stuff (e.g. configuring alloed ssh users) are still tricky since we're running on a different IP and using a different user. But with this in mind, playbooks can be written to cope with this upfront. |
I ran into the same issue using vagrant-ansible almost right away; By using the temporary inventory file, none of my group_vars and host_vars got used, making my playbooks (which use them heavily) rather useless. I ended up having to pass in my existing inventory file to
The |
This enables a vagrant user to create a more realistic test environment if they use the name of their hosts in the inventory file (e.g. if they use the inventory file to create bind9 config)