{"id":15286323,"url":"https://github.com/goodhosts/vagrant","last_synced_at":"2025-04-13T03:10:06.427Z","repository":{"id":40269316,"uuid":"265793053","full_name":"goodhosts/vagrant","owner":"goodhosts","description":"Vagrant plugin that use goodhosts to manipulate hosts files","archived":false,"fork":false,"pushed_at":"2024-01-26T09:34:14.000Z","size":201,"stargazers_count":19,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T03:09:54.721Z","etag":null,"topics":["hacktoberfest","hosts","vagrant","vagrant-plugin"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/vagrant-goodhosts/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goodhosts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-21T08:17:01.000Z","updated_at":"2025-03-16T06:10:22.000Z","dependencies_parsed_at":"2024-01-26T11:49:55.689Z","dependency_job_id":null,"html_url":"https://github.com/goodhosts/vagrant","commit_stats":{"total_commits":215,"total_committers":46,"mean_commits":4.673913043478261,"dds":0.5581395348837209,"last_synced_commit":"bb656fdf63df9e7ece23578a88b65f158b96b0ff"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodhosts%2Fvagrant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodhosts%2Fvagrant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodhosts%2Fvagrant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodhosts%2Fvagrant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goodhosts","download_url":"https://codeload.github.com/goodhosts/vagrant/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657917,"owners_count":21140846,"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":["hacktoberfest","hosts","vagrant","vagrant-plugin"],"created_at":"2024-09-30T15:12:52.761Z","updated_at":"2025-04-13T03:10:06.395Z","avatar_url":"https://github.com/goodhosts.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vagrant::Goodhosts\n\nThis vagrant plugin adds host file entries to the host pointing to the guest VM, using the [GoodHosts](https://github.com/goodhosts/cli) cli tool. This plugin is based on [vagrant-hostsupdater](https://github.com/cogitatio/vagrant-hostsupdater) and aims to be compatible with the same config parameters.\n\nOn **up**, **resume** and **reload** commands, it tries to add the hosts if they do not already exist in your hosts file. If it needs to be added, you will be asked for the `sudo` password to make the necessary edits.\n\nOn **halt**, **destroy**, and **suspend**, those entries will be removed again. By setting the `config.goodhosts.remove_on_suspend  = false`, **suspend** and **halt** will not remove them.\n\n## Installation\n\n```shell\nvagrant plugin install vagrant-goodhosts\n```\n\nTo uninstall :\n\n```shell\nvagrant plugin uninstall vagrant-goodhosts\n```\n\nTo update the plugin:\n\n```shell\nvagrant plugin update vagrant-goodhosts\n```\n\n### Installation from Gem file\n\nThe gem file is released with every [release](https://github.com/goodhosts/vagrant/releases) and you can install it with vagrant as it is a plugin after all.  \nAffter downloading the file run this command to install manually:\n\n`vagrant plugin install vagrant-goodhosts-*.gem`\n\n## Usage\n\nYou currently only need the `hostname` and a `:private_network` network with a fixed IP address.\n\n```ruby\nconfig.vm.network :private_network, ip: \"192.168.3.10\"\nconfig.vm.hostname = \"www.testing.de\" # This is not used by the plugin\nconfig.goodhosts.aliases = [\"alias.testing.de\", \"alias2.somedomain.com\"]\n```\n\nThis IP address and the hostname will be used for the entry in the `/etc/hosts` file.\n\n### vagrant-hostsupdater conflicts\n\nThe original plugin has the issue of be executed in any vagrant environment, also that is not using and will add a rule in the hosts file that is not generated by this one.\nTo avoid issues is better to remove that plugin and in case update accordingly the Vagrantfile if use it. Require just a change of the reference of the plugin name as the example above.\n\n### Multiple private network adapters\n\nIf you have multiple network adapters i.e.:\n\n```ruby\nconfig.vm.network :private_network, ip: \"10.0.0.1\"\nconfig.vm.network :private_network, ip: \"10.0.0.2\"\n```\n\nYou can specify which hostnames are bound to which IP by passing a hash mapping the IP of the network to an array of hostnames to create, e.g.:\n\n```ruby\nconfig.goodhosts.aliases = {\n    '10.0.0.1' =\u003e ['foo.com', 'bar.com'],\n    '10.0.0.2' =\u003e ['baz.com', 'bat.com']\n}\n```\n\nThis will produce `/etc/hosts` entries like so:\n\n```\n10.0.0.1 foo.com\n10.0.0.1 bar.com\n10.0.0.2 baz.com\n10.0.0.2 bat.com\n```\n\n### Keeping Host Entries After Suspend/Halt\n\nTo keep your `/etc/hosts` file unchanged simply add the line below to your `VagrantFile`:\n\n```ruby\nconfig.goodhosts.remove_on_suspend = false\n```\n\nThis disables `vagrant-goodhosts` from running on **suspend** and **halt**.\n\n### Disable file hosts clean\n\nIf you want `/etc/hosts` file cleaned add in your `VagrantFile`:\n\n```ruby\nconfig.goodhosts.disable_clean = false\n```\n\nThis enable `vagrant-goodhosts` from running the clean command in every call.\n\n## Suppressing prompts for elevating privileges\n\nThese prompts exist to prevent anything that is being run by the user from inadvertently updating the hosts file.  \nThe command path is printed in red when there are errors with Vagrant eg. if the sudo password is entered incorrectly for 3 times.  \nIf you understand the risks that go with supressing them, here's how to do it.\n\n### Linux/OS X: Passwordless sudo\n\nTo allow vagrant to automatically update the hosts file without asking for a sudo password, add one of the following snippets to a new sudoers file include, i.e. `sudo visudo -f /etc/sudoers.d/vagrant_goodhosts`.\nThe command path is printed when there are errors with Vagrant, check the output marked in red.\n\nFor Ubuntu and most Linux environments:\n\n    %sudo ALL=(root) NOPASSWD: [the-command-path]\n\nAn example complete:\n\n    %sudo ALL=(root) NOPASSWD: /home/user/sites/vvv/.vagrant/plugins/gems/3.1.2/gems/vagrant-goodhosts-1.1.6/lib/vagrant-goodhosts/bundle/cli_amd64_linux\n\nFor MacOS:\n\n    %admin ALL=(root) NOPASSWD: [the-command-path]\n\nReplace in both %sudo/%admin with the username it if it is not working for you.\n\n### Windows: UAC Prompt\n\nYou can use `cacls` or `icacls` to grant your user account permanent write permission to the system's hosts file.\nYou have to open an elevated command prompt; hold `❖ Win` and press `X`, then choose \"Command Prompt (Admin)\"\n\n    cacls %SYSTEMROOT%\\system32\\drivers\\etc\\hosts /E /G %USERNAME%:W\n\n## Generate The Development Version\n\nIf you would like to install `vagrant-goodhosts` to make contributions or changes, run the following commands::\n\n```shell\ngit clone https://github.com/goodhosts/vagrant vagrant-goodhosts\ncd vagrant-goodhosts\n./package.sh\nvagrant plugin install vagrant-goodhosts-*.gem\n```\n\n## Test the plugin\n\nYou need to run a Vagrant machine with the minimum settings specified in the [Usage](https://github.com/goodhosts/vagrant#usage) section, it is enough a turn on and off and in the meantime if the hosts file in your machine is written in the right way.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoodhosts%2Fvagrant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoodhosts%2Fvagrant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoodhosts%2Fvagrant/lists"}