All Projects β†’ devopsgroup-io β†’ Vagrant Hostmanager

devopsgroup-io / Vagrant Hostmanager

Licence: mpl-2.0
πŸ“ A Vagrant plugin that manages hosts files within a multi-machine environment.

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Vagrant Hostmanager

Hblock
Improve your security and privacy by blocking ads, tracking and malware domains.
Stars: ✭ 724 (-49.79%)
Mutual labels:  dns, hosts, hostsfile
Virtual Hosts
hosts for android,implement by vpn mode,supports wildcard DNS records
Stars: ✭ 465 (-67.75%)
Mutual labels:  dns, hosts
Polish Ads Filter
CertyficateIT - Oficjalne polskie filtry do Adblock, uBlock Origin, Adguard
Stars: ✭ 462 (-67.96%)
Mutual labels:  hosts, hostsfile
Hosts For Surge
🌟 Hosts for Internet Freedom
Stars: ✭ 514 (-64.36%)
Mutual labels:  dns, hosts
GameIndustry-hosts-Template
Unique host templates to enhance own privacy in games, websites and regulary software on Desktop and Android devices
Stars: ✭ 25 (-98.27%)
Mutual labels:  hosts, hostsfile
Google Hosts
Google hosts generator
Stars: ✭ 3,277 (+127.25%)
Mutual labels:  hosts, hostsfile
Mobile Hosts
HOSTS files converted or sourced from various filter lists to prevent ads and tracking.
Stars: ✭ 91 (-93.69%)
Mutual labels:  hosts, hostsfile
autohosts
Automate hosts file updates on Linux and MacOS. Block Firefox telemetry, Google snooping and web trackers at the root.
Stars: ✭ 69 (-95.21%)
Mutual labels:  hosts, hostsfile
Funceble
[ARCHIVED] Please report to https://github.com/funilrys/PyFunceble.
Stars: ✭ 25 (-98.27%)
Mutual labels:  hosts, hostsfile
Hostctl
Your dev tool to manage /etc/hosts like a pro!
Stars: ✭ 642 (-55.48%)
Mutual labels:  dns, hostsfile
hosts
πŸ„―Curated lists of hosts files with various domain blocks.πŸ„―
Stars: ✭ 15 (-98.96%)
Mutual labels:  hosts, hostsfile
Python Hosts
a hosts file manager library written in python
Stars: ✭ 90 (-93.76%)
Mutual labels:  hosts, hostsfile
DNS-Sinkhole-Lists-A2
A DNS Sinkhole List for testing purposes. (not for use in production systems) - UUID: 0f90ca2c-4b0a-4fbe-b659-449ab30c4284
Stars: ✭ 19 (-98.68%)
Mutual labels:  dns, hosts
Wally3k.github.io
Repo for Firebog hosting
Stars: ✭ 427 (-70.39%)
Mutual labels:  hosts, hostsfile
zonemanager
Central DNS/DHCP database with replication to Amazon Route53, BIND, MikroTik routers and other services.
Stars: ✭ 29 (-97.99%)
Mutual labels:  dns, hosts
Blacklist
Curated and well-maintained hostfile to block ads, tracking, cryptomining, and more! Updated regularly. βš‘πŸ”’
Stars: ✭ 492 (-65.88%)
Mutual labels:  hosts, hostsfile
additional-hosts
πŸ›‘ List of categorized undesired hosts
Stars: ✭ 13 (-99.1%)
Mutual labels:  hosts, hostsfile
Windows.10.DNS.Block.List
Windows DNS Block List
Stars: ✭ 18 (-98.75%)
Mutual labels:  dns, hosts
Ultimate.hosts.blacklist
The Ultimate Unified Hosts file for protecting your network, computer, smartphones and Wi-Fi devices against millions of bad web sites. Protect your children and family from gaining access to bad web sites and protect your devices and pc from being infected with Malware or Ransomware.
Stars: ✭ 606 (-57.98%)
Mutual labels:  hosts, hostsfile
1hosts
DNS filter-/blocklists | safe. private. clean. browsing!
Stars: ✭ 85 (-94.11%)
Mutual labels:  dns, hostsfile

Vagrant Host Manager

Gem Gem Gem Twitter

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.

Do 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. Patreon

Installation

$ vagrant plugin install vagrant-hostmanager

Usage

To update the hosts file on each active machine, run the following command:

$ vagrant hostmanager

The plugin hooks into the vagrant up and vagrant destroy commands automatically. When a machine enters or exits the running state , all active machines with the same provider will have their hosts file updated accordingly. Set the hostmanager.enabled attribute to true in the Vagrantfile to activate this behavior.

To update the host's hosts file, set the hostmanager.manage_host attribute to true.

To update the guests' hosts file, set the hostmanager.manage_guest attribute to true.

A machine's IP address is defined by either the static IP for a private network configuration or by the SSH host configuration. To disable using the private network IP address, set config.hostmanager.ignore_private_ip to true.

A machine's host name is defined by config.vm.hostname. If this is not set, it falls back to the symbol defining the machine in the Vagrantfile.

If the hostmanager.include_offline attribute is set to true, boxes that are up or have a private ip configured will be added to the hosts file.

In addition, the hostmanager.aliases configuration attribute can be used to provide aliases for your host names.

Example configuration:

Vagrant.configure("2") do |config|
  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.hostmanager.manage_guest = true
  config.hostmanager.ignore_private_ip = false
  config.hostmanager.include_offline = true
  config.vm.define 'example-box' do |node|
    node.vm.hostname = 'example-box-hostname'
    node.vm.network :private_network, ip: '192.168.42.42'
    node.hostmanager.aliases = %w(example-box.localdomain example-box-alias)
  end
end

Provisioner

Starting at version 1.5.0, vagrant up runs hostmanager before any provisioning occurs. If you would like hostmanager to run after or during your provisioning stage, you can use hostmanager as a provisioner. This allows you to use the provisioning order to ensure that hostmanager runs when desired. The provisioner will collect hosts from boxes with the same provider as the running box.

Example:

# Disable the default hostmanager behavior
config.hostmanager.enabled = false

# ... possible provisioner config before hostmanager ...

# hostmanager provisioner
config.vm.provision :hostmanager

# ... possible provisioning config after hostmanager ...

Custom IP resolver

You can customize way, how host manager resolves IP address for each machine. This might be handy in case of aws provider, where host name is stored in ssh_info hash of each machine. This causes generation of invalid /etc/hosts file.

Custom IP resolver gives you oportunity to calculate IP address for each machine by yourself, giving You also access to the machine that is updating /etc/hosts. For example:

config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
  if hostname = (vm.ssh_info && vm.ssh_info[:host])
    `host #{hostname}`.split("\n").last[/(\d+\.\d+\.\d+\.\d+)/, 1]
  end
end

Passwordless sudo

To avoid being asked for the password every time the hosts file is updated, enable passwordless sudo for the specific command that hostmanager uses to update the hosts file.

  • Add the following snippet to the sudoers file (e.g. /etc/sudoers.d/vagrant_hostmanager):

    Cmnd_Alias VAGRANT_HOSTMANAGER_UPDATE = /bin/cp <home-directory>/.vagrant.d/tmp/hosts.local /etc/hosts
    %<admin-group> ALL=(root) NOPASSWD: VAGRANT_HOSTMANAGER_UPDATE
    

    Replace <home-directory> with your actual home directory (e.g. /home/joe) and <admin-group> with the group that is used by the system for sudo access (usually sudo on Debian/Ubuntu systems and wheel on Fedora/Red Hat systems).

  • If necessary, add yourself to the <admin-group>:

    usermod -aG <admin-group> <user-name>
    

    Replace <admin-group> with the group that is used by the system for sudo access (see above) and <user-name> with you user name.

Windows support

Hostmanager will detect Windows guests and hosts and use the appropriate path for the hosts file: %WINDIR%\System32\drivers\etc\hosts

By default on a Windows host, the hosts file is not writable without elevated privileges. If hostmanager detects that it cannot overwrite the file, it will attempt to do so with elevated privileges, causing the UAC prompt to appear.

To avoid the UAC prompt, open %WINDIR%\System32\drivers\etc\ in Explorer, right-click the hosts file, go to Properties > Security > Edit and give your user Modify permission.

UAC limitations

Due to limitations caused by UAC, cancelling out of the UAC prompt will not cause any visible errors, however the hosts file will not be updated.

Compatibility

This Vagrant plugin has been tested with the following host and guest operating system combinations.

Date Tested Vagrant Version vagrant-hostmanager Version Host (Workstation) Operating System Guest (VirtualBox) Operating System
03/23/2016 1.8.1 1.8.1 Ubuntu 14.04 LTS CentOS 7.2
03/22/2016 1.8.1 1.8.1 OS X 10.11.4 CentOS 7.2
05/03/2017 1.9.4 1.8.6 macOS 10.12.4 Windows Server 2012 R2

Troubleshooting

  • Version 1.1 of the plugin prematurely introduced a feature to hook into commands other than vagrant up and vagrant destroy. Version 1.1 broke support for some providers. Version 1.2 reverts this feature until a suitable implementation supporting all providers is available.

  • Potentially breaking change in v1.5.0: the running order on vagrant up has changed so that hostmanager runs before provisioning takes place. This ensures all hostnames are available to the guest when it is being provisioned (see #73). Previously, hostmanager would run as the very last action. If you depend on the old behavior, see the provisioner section.

Contribute

To contribute, fork then clone the repository, and then the following:

Developing

  1. Ideally, install the version of Vagrant as defined in the Gemfile
  2. Install Ruby
  3. Currently the Bundler version is locked to 1.14.6, please install this version.
    • gem install bundler -v '1.14.6'
  4. Then install vagrant-hostmanager dependancies:
    • bundle _1.14.6_ install

Testing

  1. Build and package your newly developed code:
    • rake gem:build
  2. Then install the packaged plugin:
    • vagrant plugin install pkg/vagrant-hostmanager-*.gem
  3. Once you're done testing, roll-back to the latest released version:
    • vagrant plugin uninstall vagrant-hostmanager
    • vagrant plugin install vagrant-hostmanager
  4. Once you're satisfied developing and testing your new code, please submit a pull request for review.

Releasing

To release a new version of vagrant-hostmanager you will need to do the following:

(only contributors of the GitHub repo and owners of the project at RubyGems will have rights to do this)

  1. First, bump, commit, and push the version in ~/lib/vagrant-hostmanager/version.rb:
  2. Then, create a matching GitHub Release (this will also create a tag):
  3. You will then need to build and push the new gem to RubyGems:
    • rake gem:build
    • gem push pkg/vagrant-hostmanager-1.6.1.gem
  4. Then, when John Doe runs the following, they will receive the updated vagrant-hostmanager plugin:
    • vagrant plugin update
    • vagrant plugin update vagrant-hostmanager
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].