{"id":13512320,"url":"https://github.com/devopsgroup-io/vagrant-hostmanager","last_synced_at":"2025-04-07T23:12:38.622Z","repository":{"id":7697666,"uuid":"9061947","full_name":"devopsgroup-io/vagrant-hostmanager","owner":"devopsgroup-io","description":":pencil: A Vagrant plugin that manages hosts files within a multi-machine environment.","archived":false,"fork":false,"pushed_at":"2023-07-30T19:48:52.000Z","size":192,"stargazers_count":1465,"open_issues_count":78,"forks_count":147,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-03-31T22:24:26.382Z","etag":null,"topics":["development-environment","dns","hosts","hostsfile","vagrant-plugin","virtual-machine"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devopsgroup-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-03-27T19:33:12.000Z","updated_at":"2025-03-30T00:40:38.000Z","dependencies_parsed_at":"2024-01-13T19:39:37.067Z","dependency_job_id":"36c8f4ac-a033-44a1-9006-ae7199687cb1","html_url":"https://github.com/devopsgroup-io/vagrant-hostmanager","commit_stats":{"total_commits":159,"total_committers":40,"mean_commits":3.975,"dds":0.7987421383647799,"last_synced_commit":"2b75b7f00f4b929023c7d6e3cd70d75b334c560b"},"previous_names":["smdahlen/vagrant-hostmanager"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devopsgroup-io%2Fvagrant-hostmanager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devopsgroup-io%2Fvagrant-hostmanager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devopsgroup-io%2Fvagrant-hostmanager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devopsgroup-io%2Fvagrant-hostmanager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devopsgroup-io","download_url":"https://codeload.github.com/devopsgroup-io/vagrant-hostmanager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744335,"owners_count":20988783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["development-environment","dns","hosts","hostsfile","vagrant-plugin","virtual-machine"],"created_at":"2024-08-01T03:01:43.673Z","updated_at":"2025-04-07T23:12:38.582Z","avatar_url":"https://github.com/devopsgroup-io.png","language":"Ruby","readme":"Vagrant Host Manager\n====================\n\n[![Gem](https://img.shields.io/gem/v/vagrant-hostmanager.svg)](https://rubygems.org/gems/vagrant-hostmanager)\n[![Gem](https://img.shields.io/gem/dt/vagrant-hostmanager.svg)](https://rubygems.org/gems/vagrant-hostmanager)\n[![Gem](https://img.shields.io/gem/dtv/vagrant-hostmanager.svg)](https://rubygems.org/gems/vagrant-hostmanager)\n[![Twitter](https://img.shields.io/twitter/url/https/github.com/devopsgroup-io/vagrant-hostmanager.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20this%20awesome%20Vagrant%20plugin%21\u0026url=https%3A%2F%2Fgithub.com%devopsgroup-io%2Fvagrant-hostmanager\u0026hashtags=vagrant%hostmanager\u0026original_referer=)\n\n`vagrant-hostmanager` is a Vagrant plugin that manages the `hosts` file on guest machines (and optionally the host). Its goal is to enable resolution of multi-machine environments deployed with a cloud provider where IP addresses are not known in advance.\n\nDo you like what we do? Consider supporting us through Patreon. All of the money goes directly back into growing our collection of open source and free software.\n[![Patreon](https://img.shields.io/badge/patreon-donate-red.svg)](https://www.patreon.com/devopsgroup)\n\nInstallation\n------------\n\n    $ vagrant plugin install vagrant-hostmanager\n\nUsage\n-----\nTo update the `hosts` file on each active machine, run the following\ncommand:\n\n    $ vagrant hostmanager\n\nThe plugin hooks into the `vagrant up` and `vagrant destroy` commands\nautomatically.\nWhen a machine enters or exits the running state , all active\nmachines with the same provider will have their `hosts` file updated\naccordingly. Set the `hostmanager.enabled` attribute to `true` in the\nVagrantfile to activate this behavior.\n\nTo update the host's `hosts` file, set the `hostmanager.manage_host`\nattribute to `true`.\n\nTo update the guests' `hosts` file, set the `hostmanager.manage_guest`\nattribute to `true`.\n\nA machine's IP address is defined by either the static IP for a private\nnetwork configuration or by the SSH host configuration. To disable\nusing the private network IP address, set `config.hostmanager.ignore_private_ip`\nto true.\n\nA machine's host name is defined by `config.vm.hostname`. If this is not\nset, it falls back to the symbol defining the machine in the Vagrantfile.\n\nIf the `hostmanager.include_offline` attribute is set to `true`, boxes that are\nup or have a private ip configured will be added to the hosts file.\n\nIn addition, the `hostmanager.aliases` configuration attribute can be used\nto provide aliases for your host names.\n\nExample configuration:\n\n```ruby\nVagrant.configure(\"2\") do |config|\n  config.hostmanager.enabled = true\n  config.hostmanager.manage_host = true\n  config.hostmanager.manage_guest = true\n  config.hostmanager.ignore_private_ip = false\n  config.hostmanager.include_offline = true\n  config.vm.define 'example-box' do |node|\n    node.vm.hostname = 'example-box-hostname'\n    node.vm.network :private_network, ip: '192.168.42.42'\n    node.hostmanager.aliases = %w(example-box.localdomain example-box-alias)\n  end\nend\n```\n\n### Provisioner\n\nStarting at version 1.5.0, `vagrant up` runs hostmanager before any provisioning occurs. \nIf you would like hostmanager to run after or during your provisioning stage, \nyou can use hostmanager as a provisioner.  This allows you to use the provisioning \norder to ensure that hostmanager runs when desired. The provisioner will collect\nhosts from boxes with the same provider as the running box.\n\nExample:\n\n```ruby\n# Disable the default hostmanager behavior\nconfig.hostmanager.enabled = false\n\n# ... possible provisioner config before hostmanager ...\n\n# hostmanager provisioner\nconfig.vm.provision :hostmanager\n\n# ... possible provisioning config after hostmanager ...\n```\n\nCustom IP resolver\n------------------\n\nYou can customize way, how host manager resolves IP address\nfor each machine. This might be handy in case of aws provider,\nwhere host name is stored in ssh_info hash of each machine.\nThis causes generation of invalid /etc/hosts file.\n\nCustom IP resolver gives you oportunity to calculate IP address\nfor each machine by yourself, giving You also access to the machine that is\nupdating /etc/hosts. For example:\n\n```ruby\nconfig.hostmanager.ip_resolver = proc do |vm, resolving_vm|\n  if hostname = (vm.ssh_info \u0026\u0026 vm.ssh_info[:host])\n    `host #{hostname}`.split(\"\\n\").last[/(\\d+\\.\\d+\\.\\d+\\.\\d+)/, 1]\n  end\nend\n```\n\nPasswordless sudo\n-----------------\n\nTo avoid being asked for the password every time the hosts file is updated,\nenable passwordless sudo for the specific command that hostmanager uses to\nupdate the hosts file.\n\n  - Add the following snippet to the sudoers file (e.g.\n    `/etc/sudoers.d/vagrant_hostmanager`):\n\n    ```\n    Cmnd_Alias VAGRANT_HOSTMANAGER_UPDATE = /bin/cp \u003chome-directory\u003e/.vagrant.d/tmp/hosts.local /etc/hosts\n    %\u003cadmin-group\u003e ALL=(root) NOPASSWD: VAGRANT_HOSTMANAGER_UPDATE\n    ```\n\n    Replace `\u003chome-directory\u003e` with your actual home directory (e.g.\n    `/home/joe`) and `\u003cadmin-group\u003e` with the group that is used by the system\n    for sudo access (usually `sudo` on Debian/Ubuntu systems and `wheel`\n    on Fedora/Red Hat systems).\n\n  - If necessary, add yourself to the `\u003cadmin-group\u003e`:\n\n    ```\n    usermod -aG \u003cadmin-group\u003e \u003cuser-name\u003e\n    ```\n\n    Replace `\u003cadmin-group\u003e` with the group that is used by the system for sudo\n    access (see above) and `\u003cuser-name\u003e` with you user name.\n\nWindows support\n---------------\n\nHostmanager will detect Windows guests and hosts and use the appropriate\npath for the ```hosts``` file: ```%WINDIR%\\System32\\drivers\\etc\\hosts```\n\nBy default on a Windows host, the ```hosts``` file is not writable without\nelevated privileges. If hostmanager detects that it cannot overwrite the file,\nit will attempt to do so with elevated privileges, causing the\n[UAC](http://en.wikipedia.org/wiki/User_Account_Control) prompt to appear.\n\nTo avoid the UAC prompt, open ```%WINDIR%\\System32\\drivers\\etc\\``` in\nExplorer, right-click the hosts file, go to Properties \u003e Security \u003e Edit\nand give your user Modify permission.\n\n### UAC limitations\n\nDue to limitations caused by UAC, cancelling out of the UAC prompt will not cause any\nvisible errors, however the ```hosts``` file will not be updated.\n\n\nCompatibility\n-------------\nThis Vagrant plugin has been tested with the following host and guest operating system combinations.\n\nDate Tested | Vagrant Version | vagrant-hostmanager Version | Host (Workstation) Operating System | Guest (VirtualBox) Operating System\n------------|-----------------|-----------------------------|-------------------------------------|--------------------------------------\n03/23/2016  | 1.8.1           | 1.8.1                       | Ubuntu 14.04 LTS                    | CentOS 7.2\n03/22/2016  | 1.8.1           | 1.8.1                       | OS X 10.11.4                        | CentOS 7.2\n05/03/2017  | 1.9.4           | 1.8.6                       | macOS 10.12.4                       | Windows Server 2012 R2\n\n\nTroubleshooting\n-------------\n* Version 1.1 of the plugin prematurely introduced a feature to hook into\ncommands other than `vagrant up` and `vagrant destroy`. Version 1.1 broke support\nfor some providers. Version 1.2 reverts this feature until a suitable implementation\nsupporting all providers is available.\n\n* Potentially breaking change in v1.5.0: the running order on `vagrant up` has changed\nso that hostmanager runs before provisioning takes place.  This ensures all hostnames are \navailable to the guest when it is being provisioned \n(see [#73](https://github.com/devopsgroup-io/vagrant-hostmanager/issues/73)).\nPreviously, hostmanager would run as the very last action.  If you depend on the old behavior, \nsee the [provisioner](#provisioner) section.\n\n\nContribute\n----------\nTo contribute, fork then clone the repository, and then the following:\n\n**Developing**\n\n1. Install [RVM](https://rvm.io/rvm/install)\n2. If using MacOS, follow these [OpenSSL instructions](https://github.com/rvm/rvm/issues/5252#issuecomment-1298835941)\n3. Use Ruby v3.0.0 `rvm use 3.0.0`\n4. Run `bundle install`\n\n**Testing**\n\n1. Build and package your newly developed code:\n    * `rake gem:build`\n2. Then install the packaged plugin:\n    * `vagrant plugin install pkg/vagrant-hostmanager-*.gem`\n3. Once you're done testing, roll-back to the latest released version:\n    * `vagrant plugin uninstall vagrant-hostmanager`\n    * `vagrant plugin install vagrant-hostmanager`\n4. Once you're satisfied developing and testing your new code, please submit a pull request for review.\n\n**Releasing**\n\nTo release a new version of vagrant-hostmanager you will need to do the following:\n\n*(only contributors of the GitHub repo and owners of the project at RubyGems will have rights to do this)*\n\n1. First, bump, commit, and push the version in ~/lib/vagrant-hostmanager/version.rb:\n    * Follow [Semantic Versioning](http://semver.org/).\n2. Then, create a matching GitHub Release (this will also create a tag):\n    * Preface the version number with a `v`.\n    * https://github.com/devopsgroup-io/vagrant-hostmanager/releases\n3. You will then need to build and push the new gem to RubyGems:\n    * `rake gem:build`\n    * `gem push pkg/vagrant-hostmanager-1.6.1.gem`\n4. Then, when John Doe runs the following, they will receive the updated vagrant-hostmanager plugin:\n    * `vagrant plugin update`\n    * `vagrant plugin update vagrant-hostmanager`\n","funding_links":["https://www.patreon.com/devopsgroup"],"categories":["Ruby","others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevopsgroup-io%2Fvagrant-hostmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevopsgroup-io%2Fvagrant-hostmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevopsgroup-io%2Fvagrant-hostmanager/lists"}