bocoup / deployment-workflow

Modern Web Deployment Workflow

Home Page:https://deployment-workflow.bocoup.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to disable ansible making a change to my hosts file?

tafsiri opened this issue · comments

I'm wondering if this is optional, as I'd prefer to not need sudo access to launch a vm (currently ran into this provisioning the openvisconf vagrant box which is using this workflow).

Or are there some things i can comment out to skip this part of the provision? I imagine vagrant/ansible has the ip address of the virtual machine and can just use that for ssh.

You can probably just comment out the config.hostsupdater.aliases line in the Vagrantfile.

That said, while you'll still be able to ssh into the box via IP, you won't be able to access the nginx web server because it expects the domain you're accessing to match the site_fqdn variable.

I have the same concerns, @tafsiri. The use of the vagrant-hostsupdater plugin is common to many Bocoup applications, so I've gotten used to commenting out the configuration in Vagrantfiles. To Ben's point: the plugin is used for a reason, so simply disabling it is likely to break the application. I manually edit my system's hostsfile for the projects I need to work on.

I can't advocate this solution, though. It's kind of a hassle to cherry-pick changes from my working directory when making patches, and git stash always re-enables the plugin, as well.

My ideal solution would be to update the plugin itself. On startup, it could read the host's hostfile, and if it found the appropriate entries, it could exit early and give control back to Vagrant.

I considered submitting a patch for this, but the plugin has not seen any development in almost 2 years. It's MIT licensed, so we could fork it, but I'm not really interested in maintaining a Vagrant plugin. Then again, we're already suffering from the consequences of a poorly-maintained project; a new poorly-maintained project that has an additional feature is still an improvement. And if we published it under the Bocoup organization, it would be easier to share the load, should it start to see wider use.

@tafsiri / @jugglinmike there is a new maintainer of vagrant-hostsupdater who has generously agreed to implement the feature you've requested if it is well specified.

agiledivider/vagrant-hostsupdater#69 (comment)

Great! I'm going to try to make time to spec/implement that later this week.

👍

I guess my concern question is slightly different, i'm interested in whether the use of hostupdater can be optional. I.e. if we know the ip of the virtual machine, can we have the nginx server serve the files when accessed through that IP and through the extra hostname. That way if you don't want to change your /etc/hosts file, you can still just use the IP address. Does that make sense?

Sure! I'd be open to a PR that disables this section if you're in development:
https://github.com/bocoup/deployment-workflow/blob/master/deploy/ansible/roles/nginx/templates/site.conf#L31-L36

I believe you'd also need to tack default_server on the listens in the main server block too.

Applications may make assumptions about the host name. For instance: the IP would be visible in the "Host" field of HTTP requests. In that way, allowing variance undermines the consistency that Vagrant (and the plugin) are intended to promote. If hostfile modification is a non-starter, then the solution may be a non-technical one: don't use host aliasing at all.

That is how the development environment is configured on Weekly Review: see the project's Vagrantfile and development instructions.

What happens when you're simultaneously working on multiple projects that happen to want same IP?

As someone who regularly runs 2-5 different apps on a daily basis that use this workflow, being able to type in a hostname is really valuable to me. I don't want to memorize IPs or look them up all the time.

For what it is worth, I believe @jugglinmike's recent addition to vagrant-hostsupdater is the perfect middle ground (hosts file is left untouched if you edit it yourself). Additionally, this is a template--if you find vagrant-hostsupdater that onerous, you can remove it from your individual projects.

@tafsiri, will you please open a PR with a suggested approach so we can continue this discussion based on a concrete implementation? If you won't be doing so, can you please close this issue?

Also, for reference, here is the adjustment @jugglinmike recently made:
agiledivider/vagrant-hostsupdater#84

@cowboy @tkellen i'm not asking for the feature to be taken away, just to make it optional. If it cannot be done let me know and i'll close this. If the only approach to working with our system is manually updating the hosts file let me know and I'll close this. But the suggested approach is spelled out above. I believe the feature (having a readable hostname) is useful so i'm not asking anyone to memorize ip addresses if they don't want to.

I just want a way to not type my admin password (or if possible edit my hosts file at all) if all i am doing is editing a blog post on something like the OpenVis site. I don't use this in my projects at all so far, but occasionally someone will ask me to run theirs which does use this so I was bringing up an issue I had with doing that.

However since it seems like i am in the minority in this, and since I am unlikely to spend time working on a PR to address this, I'll try and remember the host file editing workaround the next time i am faced with this problem.

@tafsiri gotcha!

There is an issue upstream for this:
agiledivider/vagrant-hostsupdater#69

The project does have an active maintainer now...seems like this would be accepted if ya found the time to PR for it.

Just a quick update, I'll be testing @jugglinmike changes this week. Thanks for submitting the PR!

If all testing goes well it will be released within two weeks.

Brilliant! Thank you so much @cgsmith and @jugglinmike!