goodhosts / vagrant

Vagrant plugin that use goodhosts to manipulate hosts files
https://rubygems.org/gems/vagrant-goodhosts/
MIT License
17 stars 8 forks source link

Win10, hyper-v -> [vagrant-goodhosts] No ip address found for this virtual machine, no hosts file update! #40

Closed tangor86 closed 3 years ago

tangor86 commented 3 years ago

Hello!

after doing vagrant up, my hosts are not accessible by domain name, only if add them manually to my hosts file... image

as I understood it should have been done by goodhosts plugin? Attaching some logs and files.

log on installing goodhosts:

C:\Users\EUGENY\vvv-local>vagrant plugin install --local
Vagrant will now install the following plugins to the local project
which have been defined in current Vagrantfile:

  vagrant-goodhosts (> 0)

Press ctrl-c to cancel...
Installing the 'vagrant-goodhosts' plugin. This can take a few minutes...
Fetching micromachine-3.0.0.gem
Fetching vagrant-vbguest-0.30.0.gem
Installed the plugin 'vagrant-goodhosts (1.0.17)'!

config.yml

---

# This file is a YAML formatted file. YAML indenting is done in spaces not
# tabs, and whitespace is significant. If you don't stick to this, it will
# fail on provision

#
# IMPORTANT, if you change this file, you have to reprovision,  no exceptions
# Do this by running either this command:
# vagrant reload --provision

# Or, if your machine is already turned on:
# vagrant provision
#

# These are your websites, and their names map on to the folders they're
# located in. See the docs for how to define these, and what all the keys
# and options are
sites:

  # latest version of WordPress, can be used for client work and testing
  # Check the readme at https://github.com/Varying-Vagrant-Vagrants/custom-site-template
  wordpress-one:
    skip_provisioning: false
    description: "A standard WP install, useful for building plugins, testing things, etc"
    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
    hosts:
      - one.wordpress.test
    custom:
      wpconfig_constants:
        WP_DEBUG: true
        WP_DEBUG_LOG: true
        WP_DISABLE_FATAL_ERROR_HANDLER: true # To disable in WP 5.2 the FER mode

  wordpress-two:
    skip_provisioning: false
    description: "A standard WP install, useful for building plugins, testing things, etc"
    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
    custom:
      # locale: it_IT
      delete_default_plugins: true
      install_plugins:
        - query-monitor
    hosts:
      - two.wordpress.test

  # The following commented out site configuration will create a standard WordPress
  # site in www/example-site/ available at http://mysite.test.
  # Remember, whitespace is significant! Tabs and spaces mean different things
  #mysite:
  #  description: "My website"
  #  repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
  #  hosts:
  #    - mysite.test

  # The wordpress-develop configuration is useful for contributing to WordPress Core.
  # It uses the built WP to serve the site
  wordpress-trunk:
    skip_provisioning: true # provisioning this one takes longer, so it's disabled by default
    description: "An svn based WP Core trunk dev setup, useful for contributor days, Trac tickets, patches"
    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop.git
    hosts:
      - trunk.wordpress.test

  # The following commented out site configuration will create a environment useful
  # for contributions to the WordPress meta team, .e.g WordCamps, .org, etc:
  wordpress-meta-environment:
    skip_provisioning: true # disabled by default, this takes a long time to provision
    description: "An environment useful for contributions to the WordPress meta team."
    repo: https://github.com/WordPress/meta-environment.git
    hosts:
      - wp-meta.test
    custom:
      provision_site:
        "buddypressorg.test": true
        "jobs.wordpressnet.test": true
        "wordcamp.test": true
        "wordpressorg.test": true
        "wordpresstv.test": true

  # The following commented out site configuration will create a standard WordPress
  # site in www/example-site/ available at http://my-example-site.test.
  # Remember, whitespace is significant! Tabs and spaces mean different things
  #example-site:
  #  repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
  #  hosts:
  #    - my-example-site.test

# Utilities https://varyingvagrantvagrants.org/docs/en-US/utilities/
# are system level items that aren't websites, that install tools or packages
# the core utilities install tools such as phpmyadmin
utilities:
  core: # The core VVV utility
    - tls-ca # HTTPS SSL/TLS certificates
    - phpmyadmin # Web based database client
    #- memcached-admin # Object cache management
    #- opcache-status # opcache management
    #- webgrind # PHP Debugging
    #- mongodb # needed for Tideways/XHGui
    #- tideways # PHP profiling tool, also installs xhgui check https://varyingvagrantvagrants.org/docs/en-US/references/tideways-xhgui/
    #- nvm # Node Version Manager
    #- php56
    #- php70
    #- php71
    #- php72
    #- php73
    #- php74

# vm_config controls how Vagrant provisions the virtual machine, and can be used to
# increase the memory given to VVV and the number of CPU cores.
# It can also be used to override the default provider being used within Vagrant.

vm_config:
  # For WP core development we recommend at least 2GB ( 2048 ),
  # If you have 4GB of RAM, lower this to 768MB or you may encounter issues
  memory: 2048
  # CPU cores:
  cores: 2

  # this tells VVV to use the prebuilt box copied from the USB drive at contributor days
  # once set to false, do not change back to true, and reprovision
  # wordcamp_contributor_day_box: false

  # Due to a limitation within Vagrant, the specified provider is only respected on a clean `vagrant up`
  # as Vagrant currently restricts you to one provider per machine
  # https://www.vagrantup.com/docs/providers/basic_usage.html#vagrant-up
  # provider: virtualbox
  provider: hyperv
  # provider: parallels
  # provider: vmware_desktop

# General VVV options
general:

  # Back up Options
  # You can always backup/restore manually using vagrant ssh -c "db_backup" or vagrant ssh -c "db_restore"

  # Backup the databases to the database/backups subfolder on halt/suspend/destroy, set to false to disable
  db_backup:
      enable: false
      gzip: true
      #exclude:
      #  - wordpress-trunk

  # Import the databases if they're missing from backups
  db_restore: false

  # set to true to use a synced shared folder for MariaDB database storage
  db_share_type: false

  # GitHub token to use from composer
  #github_token: xxxxxx

# Settings for the vagrant plugins supported by VVV
vagrant-plugins:
  disksize: 10GB # requires the disk size vagrant plugin

vagrantfile

# frozen_string_literal: true

# -*- mode: ruby -*-
# vi: set ft=ruby ts=2 sw=2 et:
Vagrant.require_version '>= 2.2.4'
require 'yaml'
require 'fileutils'

def sudo_warnings
  red = "\033[38;5;9m" # 124m"
  creset = "\033[0m"
  puts "#{red}┌-──────────────────────────────────────────────────────────────────────────────┐#{creset}"
  puts "#{red}│                                                                               │#{creset}"
  puts "#{red}│  ⚠ DANGER DO NOT USE SUDO ⚠                                                   │#{creset}"
  puts "#{red}│                                                                               │#{creset}"
  puts "#{red}│ ! ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄ !  You should never use sudo or root with vagrant.          │#{creset}"
  puts "#{red}│  !█▒▒░░░░░░░░░▒▒█    It causes lots of problems :(                            │#{creset}"
  puts "#{red}│    █░░█░▄▄░░█░░█ !                                                            │#{creset}"
  puts "#{red}│     █░░█░░█░▄▄█    ! We're really sorry but you may need to do painful        │#{creset}"
  puts "#{red}│  !  ▀▄░█░░██░░█      cleanup commands to fix this.                            │#{creset}"
  puts "#{red}│                                                                               │#{creset}"
  puts "#{red}│  If vagrant does not work for you without sudo, open a GitHub issue instead   │#{creset}"
  puts "#{red}│  In the future, this warning will halt provisioning to prevent new users      │#{creset}"
  puts "#{red}│  making this mistake.                                                         │#{creset}"
  puts "#{red}│                                                                               │#{creset}"
  puts "#{red}│  ⚠ DANGER SUDO DETECTED!                                                      │#{creset}"
  puts "#{red}│                                                                               │#{creset}"
  puts "#{red}│  In the future the VVV team will be making it harder to use VVV with sudo.    │#{creset}"
  puts "#{red}│  We will require a config option so that users can do data recovery, and      │#{creset}"
  puts "#{red}│  disable sites and the dashboard.                                             │#{creset}"
  puts "#{red}│                                                                               │#{creset}"
  puts "#{red}│  DO NOT USE SUDO, use ctrl+c/cmd+c and cancel this command ASAP!!!            │#{creset}"
  puts "#{red}│                                                                               │#{creset}"
  puts "#{red}└───────────────────────────────────────────────────────────────────────────────┘#{creset}"
  # exit
end

vagrant_dir = __dir__
show_logo = false
branch_c = "\033[38;5;6m" # 111m"
red = "\033[38;5;9m" # 124m"
green = "\033[1;38;5;2m" # 22m"
blue = "\033[38;5;4m" # 33m"
purple = "\033[38;5;5m" # 129m"
docs = "\033[0m"
yellow = "\033[38;5;3m" # 136m"
yellow_underlined = "\033[4;38;5;3m" # 136m"
url = yellow_underlined
creset = "\033[0m"

version = '?'
File.open("#{vagrant_dir}/version", 'r') do |f|
  version = f.read
  version = version.gsub("\n", '')
end

unless Vagrant::Util::Platform.windows?
  if Process.uid == 0
    sudo_warnings
  end
end

unless Vagrant::Util::Platform.windows?
  if Process.uid == 0
    puts " "
    puts "#{red} ⚠ DANGER VAGRANT IS RUNNING AS ROOT/SUDO, DO NOT USE SUDO ⚠#{creset}"
    puts " "
  end
end

# whitelist when we show the logo, else it'll show on global Vagrant commands
show_logo = true if %w[up resume status provision reload].include? ARGV[0]
show_logo = false if ENV['VVV_SKIP_LOGO']

# Show the initial splash screen
if show_logo
  git_or_zip = 'zip-no-vcs'
  branch = ''
  commit = ''
  if File.directory?("#{vagrant_dir}/.git")
    git_or_zip = 'git::'
    branch = `git --git-dir="#{vagrant_dir}/.git" --work-tree="#{vagrant_dir}" rev-parse --abbrev-ref HEAD`
    branch = branch.chomp("\n"); # remove trailing newline so it doesn't break the ascii art
    commit = `git --git-dir="#{vagrant_dir}/.git" --work-tree="#{vagrant_dir}" rev-parse --short HEAD`
    commit = '(' + commit.chomp("\n") + ')'; # remove trailing newline so it doesn't break the ascii art
  end

  splashfirst = <<~HEREDOC
    \033[1;38;5;196m#{red}__ #{green}__ #{blue}__ __
    #{red}\\ V#{green}\\ V#{blue}\\ V / #{purple}v#{version} #{purple}Path:"#{vagrant_dir}"
    #{red} \\_/#{green}\\_/#{blue}\\_/  #{creset}#{branch_c}#{git_or_zip}#{branch}#{commit}#{creset}

  HEREDOC
  puts splashfirst
end

# Load the config file before the second section of the splash screen

# Perform file migrations from older versions
vvv_config_file = File.join(vagrant_dir, 'config/config.yml')
unless File.file?(vvv_config_file)
  old_vvv_config = File.join(vagrant_dir, 'vvv-custom.yml')
  if File.file?(old_vvv_config)
    puts "#{yellow}Migrating #{red}vvv-custom.yml#{yellow} to #{green}config/config.yml#{yellow}\nIMPORTANT NOTE: Make all modifications to #{green}config/config.yml#{yellow}.#{creset}\n\n"
    FileUtils.mv(old_vvv_config, vvv_config_file)
  else
    puts "#{yellow}Copying #{red}config/default-config.yml#{yellow} to #{green}config/config.yml#{yellow}\nIMPORTANT NOTE: Make all modifications to #{green}config/config.yml#{yellow} in future so that they are not lost when VVV updates.#{creset}\n\n"
    FileUtils.cp(File.join(vagrant_dir, 'config/default-config.yml'), vvv_config_file)
  end
end

old_db_backup_dir = File.join(vagrant_dir, 'database/backups/')
new_db_backup_dir = File.join(vagrant_dir, 'database/sql/backups/')
if (File.directory?(old_db_backup_dir) == true) && (File.directory?(new_db_backup_dir) == false)
  puts 'Moving db backup directory into database/sql/backups'
  FileUtils.mv(old_db_backup_dir, new_db_backup_dir)
end

begin
  vvv_config = YAML.load_file(vvv_config_file)
  unless vvv_config['sites'].is_a? Hash
    vvv_config['sites'] = {}

    puts "#{red}config/config.yml is missing a sites section.#{creset}\n\n"
  end
rescue StandardError => e
  puts "#{red}config/config.yml isn't a valid YAML file.#{creset}\n\n"
  puts "#{red}VVV cannot be executed!#{creset}\n\n"

  warn e.message
  exit
end

vvv_config['hosts'] = [] unless vvv_config['hosts'].is_a? Hash

vvv_config['hosts'] += ['vvv.test']

vvv_config['sites'].each do |site, args|
  if args.is_a? String
    repo = args
    args = {}
    args['repo'] = repo
  end

  args = {} unless args.is_a? Hash

  defaults = {}
  defaults['repo'] = false
  defaults['vm_dir'] = "/srv/www/#{site}"
  defaults['local_dir'] = File.join(vagrant_dir, 'www', site)
  defaults['branch'] = 'master'
  defaults['skip_provisioning'] = false
  defaults['allow_customfile'] = false
  defaults['nginx_upstream'] = 'php'
  defaults['hosts'] = []

  vvv_config['sites'][site] = defaults.merge(args)

  unless vvv_config['sites'][site]['skip_provisioning']
    site_host_paths = Dir.glob(Array.new(4) { |i| vvv_config['sites'][site]['local_dir'] + '/*' * (i + 1) + '/vvv-hosts' })
    vvv_config['sites'][site]['hosts'] += site_host_paths.map do |path|
      lines = File.readlines(path).map(&:chomp)
      lines.grep(/\A[^#]/)
    end.flatten
    if vvv_config['sites'][site]['hosts'].is_a? Array
      vvv_config['hosts'] += vvv_config['sites'][site]['hosts']
    else
      vvv_config['hosts'] += ["#{site}.test"]
    end
  end
  vvv_config['sites'][site].delete('hosts')
end

if vvv_config['utility-sources'].is_a? Hash
  vvv_config['utility-sources'].each do |name, args|
    next unless args.is_a? String

    repo = args
    args = {}
    args['repo'] = repo
    args['branch'] = 'master'

    vvv_config['utility-sources'][name] = args
  end
else
  vvv_config['utility-sources'] = {}
end

vvv_config['dashboard'] = {} unless vvv_config['dashboard']
dashboard_defaults = {}
dashboard_defaults['repo'] = 'https://github.com/Varying-Vagrant-Vagrants/dashboard.git'
dashboard_defaults['branch'] = 'master'
vvv_config['dashboard'] = dashboard_defaults.merge(vvv_config['dashboard'])

unless vvv_config['utility-sources'].key?('core')
  vvv_config['utility-sources']['core'] = {}
  vvv_config['utility-sources']['core']['repo'] = 'https://github.com/Varying-Vagrant-Vagrants/vvv-utilities.git'
  vvv_config['utility-sources']['core']['branch'] = 'master'
end

vvv_config['utilities'] = {} unless vvv_config['utilities'].is_a? Hash

vvv_config['vm_config'] = {} unless vvv_config['vm_config'].is_a? Hash

vvv_config['general'] = {} unless vvv_config['general'].is_a? Hash

defaults = {}
defaults['memory'] = 2048
defaults['cores'] = 1
defaults['provider'] = 'virtualbox'
# This should rarely be overridden, so it's not included in the config/default-config.yml file.
defaults['private_network_ip'] = '192.168.50.4'

vvv_config['vm_config'] = defaults.merge(vvv_config['vm_config'])
vvv_config['hosts'] = vvv_config['hosts'].uniq

vvv_config['vagrant-plugins'] = {} unless vvv_config['vagrant-plugins']

# Create a global variable to use in functions and classes
$vvv_config = vvv_config

# Show the second splash screen section

if show_logo
  platform = [ Vagrant::Util::Platform.platform]
  if Vagrant::Util::Platform.windows?
    platform << 'windows '
    platform << 'wsl ' if Vagrant::Util::Platform.wsl?
    platform << 'msys ' if Vagrant::Util::Platform.msys?
    platform << 'cygwin ' if Vagrant::Util::Platform.cygwin?
    if Vagrant::Util::Platform.windows_hyperv_enabled?
      platform << 'HyperV-Enabled '
    end
    platform << 'HyperV-Admin ' if Vagrant::Util::Platform.windows_hyperv_admin?
    if Vagrant::Util::Platform.windows_admin?
      platform << 'HasWinAdminPriv '
    else
      platform << 'missingWinAdminPriv ' unless Vagrant::Util::Platform.windows_admin?
    end
  else
    platform << 'shell:' + ENV['SHELL'] if ENV['SHELL']
    platform << 'systemd ' if Vagrant::Util::Platform.systemd?
  end

  platform << 'vagrant-hostmanager' if Vagrant.has_plugin?('vagrant-hostmanager')
  platform << 'vagrant-hostsupdater' if Vagrant.has_plugin?('vagrant-hostsupdater')
  platform << 'vagrant-goodhosts' if Vagrant.has_plugin?('vagrant-goodhosts')
  platform << 'vagrant-vbguest' if Vagrant.has_plugin?('vagrant-vbguest')
  platform << 'vagrant-disksize' if Vagrant.has_plugin?('vagrant-disksize')

  platform << 'CaseSensitiveFS' if Vagrant::Util::Platform.fs_case_sensitive?
  unless Vagrant::Util::Platform.terminal_supports_colors?
    platform << 'monochrome-terminal'
  end

  if defined? vvv_config['vm_config']['wordcamp_contributor_day_box']
    if vvv_config['vm_config']['wordcamp_contributor_day_box'] == true
      platform << 'contributor_day_box'
    end
  end

  if defined? vvv_config['vm_config']['box']
    unless vvv_config['vm_config']['box'].nil?
      puts "Custom Box: Box overridden via config/config.yml , this won't take effect until a destroy + reprovision happens"
      platform << 'box_override:' + vvv_config['vm_config']['box']
    end
  end

  if defined? vvv_config['general']['db_share_type']
    if vvv_config['general']['db_share_type'] != true
      platform << 'shared_db_folder_disabled'
    else
      platform << 'shared_db_folder_enabled'
    end
  else
    platform << 'shared_db_folder_default'
  end

  provider_version = '??'

  provider_meta = nil

  case vvv_config['vm_config']['provider']
  when 'virtualbox'
    provider_meta = VagrantPlugins::ProviderVirtualBox::Driver::Meta.new()
    provider_version = provider_meta.version
  when 'parallels'
    provider_meta = VagrantPlugins::Parallels::Driver::Meta.new()
    provider_version = provider_meta.version
  when 'vmware'
    provider_version = '??'
  when 'hyperv'
    provider_version = 'n/a'
  else
    provider_version = '??'
  end

  splashsecond = <<~HEREDOC
    #{yellow}Platform: #{yellow}#{platform.join(' ')}
    #{green}Vagrant: #{green}v#{Vagrant::VERSION}, #{blue}#{vvv_config['vm_config']['provider']}: #{blue}v#{provider_version}

    #{docs}Docs:       #{url}https://varyingvagrantvagrants.org/
    #{docs}Contribute: #{url}https://github.com/varying-vagrant-vagrants/vvv
    #{docs}Dashboard:  #{url}http://vvv.test#{creset}

  HEREDOC
  puts splashsecond
end

if defined? vvv_config['vm_config']['provider']
  # Override or set the vagrant provider.
  ENV['VAGRANT_DEFAULT_PROVIDER'] = vvv_config['vm_config']['provider']
end

ENV['LC_ALL'] = 'en_US.UTF-8'

Vagrant.configure('2') do |config|
  # Store the current version of Vagrant for use in conditionals when dealing
  # with possible backward compatible issues.
  vagrant_version = Vagrant::VERSION.sub(/^v/, '')

  # Configurations from 1.0.x can be placed in Vagrant 1.1.x specs like the following.
  config.vm.provider :virtualbox do |v|
    v.customize ['modifyvm', :id, '--uartmode1', 'file', File.join(vagrant_dir, 'log/ubuntu-cloudimg-console.log')]
    v.customize ['modifyvm', :id, '--memory', vvv_config['vm_config']['memory']]
    v.customize ['modifyvm', :id, '--cpus', vvv_config['vm_config']['cores']]
    v.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
    v.customize ['modifyvm', :id, '--natdnsproxy1', 'on']

    # see https://github.com/hashicorp/vagrant/issues/7648
    v.customize ['modifyvm', :id, '--cableconnected1', 'on']

    v.customize ['modifyvm', :id, '--rtcuseutc', 'on']
    v.customize ['modifyvm', :id, '--audio', 'none']
    v.customize ['modifyvm', :id, '--paravirtprovider', 'kvm']

    # https://github.com/laravel/homestead/pull/63
    v.customize ['modifyvm', :id, '--ostype', 'Ubuntu_64']

    v.customize ['setextradata', :id, 'VBoxInternal2/SharedFoldersEnableSymlinksCreate//srv/www', '1']
    v.customize ['setextradata', :id, 'VBoxInternal2/SharedFoldersEnableSymlinksCreate//srv/config', '1']

    # Set the box name in VirtualBox to match the working directory.
    v.name = File.basename(vagrant_dir) + '_' + (Digest::SHA256.hexdigest vagrant_dir)[0..10]
  end

  # Configuration options for the Parallels provider.
  config.vm.provider :parallels do |v|
    v.update_guest_tools = true
    v.customize ['set', :id, '--longer-battery-life', 'off']
    v.memory = vvv_config['vm_config']['memory']
    v.cpus = vvv_config['vm_config']['cores']
  end

  # Configuration options for the VMware Desktop provider.
  config.vm.provider :vmware_desktop do |v|
    v.vmx['memsize'] = vvv_config['vm_config']['memory']
    v.vmx['numvcpus'] = vvv_config['vm_config']['cores']
  end

  # Configuration options for Hyper-V provider.
  config.vm.provider :hyperv do |v|
    v.memory = vvv_config['vm_config']['memory']
    v.cpus = vvv_config['vm_config']['cores']
    v.linked_clone = true
  end

  # Auto Download Vagrant plugins, supported from Vagrant 2.2.0
  unless Vagrant.has_plugin?('vagrant-hostsupdater') && Vagrant.has_plugin?('vagrant-goodhosts') && Vagrant.has_plugin?('vagrant-hostsmanager')
    if File.file?(File.join(vagrant_dir, 'vagrant-goodhosts.gem'))
      system('vagrant plugin install ' + File.join(vagrant_dir, 'vagrant-goodhosts.gem'))
      File.delete(File.join(vagrant_dir, 'vagrant-goodhosts.gem'))
      puts "#{yellow}VVV needed to install the vagrant-goodhosts plugin which is now installed. Please run the requested command again.#{creset}"
      exit
    else
      config.vagrant.plugins = ['vagrant-goodhosts']
    end
  end

  # The vbguest plugin has issues for some users, so we're going to disable it for now
  config.vbguest.auto_update = false if Vagrant.has_plugin?('vagrant-vbguest')

  # SSH Agent Forwarding
  #
  # Enable agent forwarding on vagrant ssh commands. This allows you to use ssh keys
  # on your host machine inside the guest. See the manual for `ssh-add`.
  config.ssh.forward_agent = true

  # SSH Key Insertion
  #
  # This is disabled, we had several contributors who ran into issues.
  # See: https://github.com/Varying-Vagrant-Vagrants/VVV/issues/1551
  config.ssh.insert_key = false

  # Default Ubuntu Box
  #
  # This box is provided by Bento boxes via vagrantcloud.com and is a nicely sized
  # box containing the Ubuntu 20.04 Focal 64 bit release. Once this box is downloaded
  # to your host computer, it is cached for future use under the specified box name.
  config.vm.box = 'bento/ubuntu-20.04'
  config.vm.box_check_update = false

  # If we're at a contributor day, switch the base box to the prebuilt one
  if defined? vvv_config['vm_config']['wordcamp_contributor_day_box']
    if vvv_config['vm_config']['wordcamp_contributor_day_box'] == true
      config.vm.box = 'vvv/contribute'
    end
  end

  # The Parallels Provider uses a different naming scheme.
  config.vm.provider :parallels do |_v, override|
    override.vm.box = 'bento/ubuntu-20.04'

    # Vagrant currently runs under Rosetta on M1 devices. As a result,
    # this seems to be the most reliable way to detect whether or not we're
    # running under ARM64.
    if Etc.uname[:version].include? 'ARM64'
      override.vm.box = 'rueian/ubuntu20-m1'
      override.vm.box_version = "0.0.1"
    end
  end

  # The VMware Desktop Provider uses a different naming scheme.
  config.vm.provider :vmware_desktop do |v, override|
    override.vm.box = 'bento/ubuntu-20.04'
    v.gui = false
  end

  # Hyper-V uses a different base box.
  config.vm.provider :hyperv do |_v, override|
    override.vm.box = 'bento/ubuntu-20.04'
  end

  if defined? vvv_config['vm_config']['box']
    unless vvv_config['vm_config']['box'].nil?
      config.vm.box = vvv_config['vm_config']['box']
    end
  end

  config.vm.hostname = 'vvv'

  # Specify disk size
  #
  # If the Vagrant plugin disksize (https://github.com/sprotheroe/vagrant-disksize) is
  # installed, the following will automatically configure your local machine's disk size
  # to be the specified size. This plugin only works on VirtualBox.
  #
  # Warning: This plugin only resizes up, not down, so don't set this to less than 10GB,
  # and if you need to downsize, be sure to destroy and reprovision.
  #
  if !vvv_config['vagrant-plugins']['disksize'].nil? && defined?(Vagrant::Disksize)
    config.vm.provider :virtualbox do |_v, override|
      override.disksize.size = vvv_config['vagrant-plugins']['disksize']
    end
  end

  # Private Network (default)
  #
  # A private network is created by default. This is the IP address through which your
  # host machine will communicate to the guest. In this default configuration, the virtual
  # machine will have an IP address of 192.168.50.4 and a virtual network adapter will be
  # created on your host machine with the IP of 192.168.50.1 as a gateway.
  #
  # Access to the guest machine is only available to your local host. To provide access to
  # other devices, a public network should be configured or port forwarding enabled.
  #
  # Note: If your existing network is using the 192.168.50.x subnet, this default IP address
  # should be changed. If more than one VM is running through VirtualBox, including other
  # Vagrant machines, different subnets should be used for each.
  #
  config.vm.network :private_network, id: 'vvv_primary', ip: vvv_config['vm_config']['private_network_ip']

  config.vm.provider :hyperv do |_v, override|
    override.vm.network :private_network, id: 'vvv_primary', ip: nil
  end

  # Public Network (disabled)
  #
  # Using a public network rather than the default private network configuration will allow
  # access to the guest machine from other devices on the network. By default, enabling this
  # line will cause the guest machine to use DHCP to determine its IP address. You will also
  # be prompted to choose a network interface to bridge with during `vagrant up`.
  #
  # Please see VVV and Vagrant documentation for additional details.
  #
  # config.vm.network :public_network

  # Port Forwarding (disabled)
  #
  # This network configuration works alongside any other network configuration in Vagrantfile
  # and forwards any requests to port 8080 on the local host machine to port 80 in the guest.
  #
  # Port forwarding is a first step to allowing access to outside networks, though additional
  # configuration will likely be necessary on our host machine or router so that outside
  # requests will be forwarded from 80 -> 8080 -> 80.
  #
  # Please see VVV and Vagrant documentation for additional details.
  #
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Drive mapping
  #
  # The following config.vm.synced_folder settings will map directories in your Vagrant
  # virtual machine to directories on your local machine. Once these are mapped, any
  # changes made to the files in these directories will affect both the local and virtual
  # machine versions. Think of it as two different ways to access the same file. When the
  # virtual machine is destroyed with `vagrant destroy`, your files will remain in your local
  # environment.

  # Disable the default synced folder to avoid overlapping mounts
  config.vm.synced_folder '.', '/vagrant', disabled: true
  config.vm.provision 'file', source: "#{vagrant_dir}/version", destination: '/home/vagrant/version'

  # /srv/database/
  #
  # If a database directory exists in the same directory as your Vagrantfile,
  # a mapped directory inside the VM will be created that contains these files.
  # This directory is used to maintain default database scripts as well as backed
  # up MariaDB/MySQL dumps (SQL files) that are to be imported automatically on vagrant up
  config.vm.synced_folder 'database/sql/', '/srv/database'
  use_db_share = false

  if defined? vvv_config['general']['db_share_type']
    use_db_share = vvv_config['general']['db_share_type'] == true
  end
  if use_db_share == true
    # Map the MySQL Data folders on to mounted folders so it isn't stored inside the VM
    config.vm.synced_folder 'database/data/', '/var/lib/mysql', create: true, owner: 9001, group: 9001, mount_options: ['dmode=775', 'fmode=664']

    # The Parallels Provider does not understand "dmode"/"fmode" in the "mount_options" as
    # those are specific to Virtualbox. The folder is therefore overridden with one that
    # uses corresponding Parallels mount options.
    config.vm.provider :parallels do |_v, override|
      override.vm.synced_folder 'database/data/', '/var/lib/mysql', create: true, owner: 9001, group: 9001, mount_options: [ 'share' ]
    end
    # Neither does the HyperV provider
    config.vm.provider :hyperv do |_v, override|
      override.vm.synced_folder 'database/data/', '/var/lib/mysql', create: true, owner: 9001, group: 9001, mount_options: ['dir_mode=0775', 'file_mode=0664']
    end
  end

  # /srv/config/
  #
  # If a server-conf directory exists in the same directory as your Vagrantfile,
  # a mapped directory inside the VM will be created that contains these files.
  # This directory is currently used to maintain various config files for php and
  # nginx as well as any pre-existing database files.
  config.vm.synced_folder 'config/', '/srv/config'

  # /srv/config/
  #
  # Map the provision folder so that utilities and provisioners can access helper scripts
  config.vm.synced_folder 'provision/', '/srv/provision'

  # /srv/certificates
  #
  # This is a location for the TLS certificates to be accessible inside the VM
  config.vm.synced_folder 'certificates/', '/srv/certificates', create: true

  # /var/log/
  #
  # If a log directory exists in the same directory as your Vagrantfile, a mapped
  # directory inside the VM will be created for some generated log files.
  config.vm.synced_folder 'log/memcached', '/var/log/memcached', owner: 'root', create: true, group: 'syslog', mount_options: ['dmode=777', 'fmode=666']
  config.vm.synced_folder 'log/nginx', '/var/log/nginx', owner: 'root', create: true, group: 'syslog', mount_options: ['dmode=777', 'fmode=666']
  config.vm.synced_folder 'log/php', '/var/log/php', create: true, owner: 'root', group: 'syslog', mount_options: ['dmode=777', 'fmode=666']
  config.vm.synced_folder 'log/provisioners', '/var/log/provisioners', create: true, owner: 'root', group: 'syslog', mount_options: ['dmode=777', 'fmode=666']

  # /srv/www/
  #
  # If a www directory exists in the same directory as your Vagrantfile, a mapped directory
  # inside the VM will be created that acts as the default location for nginx sites. Put all
  # of your project files here that you want to access through the web server
  config.vm.synced_folder 'www/', '/srv/www', owner: 'vagrant', group: 'www-data', mount_options: ['dmode=775', 'fmode=774']

  vvv_config['sites'].each do |site, args|
    next if args['skip_provisioning']
    if args['local_dir'] != File.join(vagrant_dir, 'www', site)
      config.vm.synced_folder args['local_dir'], args['vm_dir'], owner: 'vagrant', group: 'www-data', mount_options: ['dmode=775', 'fmode=774']
    end
  end

  # The Parallels Provider does not understand "dmode"/"fmode" in the "mount_options" as
  # those are specific to Virtualbox. The folder is therefore overridden with one that
  # uses corresponding Parallels mount options.
  config.vm.provider :parallels do |_v, override|
    override.vm.synced_folder 'www/', '/srv/www', owner: 'vagrant', group: 'www-data', mount_options: [ 'share' ]

    override.vm.synced_folder 'log/memcached', '/var/log/memcached', owner: 'root', create: true, group: 'syslog', mount_options: [ 'share' ]
    override.vm.synced_folder 'log/nginx', '/var/log/nginx', owner: 'root', create: true, group: 'syslog', mount_options: [ 'share' ]
    override.vm.synced_folder 'log/php', '/var/log/php', create: true, owner: 'root', group: 'syslog', mount_options: [ 'share' ]
    override.vm.synced_folder 'log/provisioners', '/var/log/provisioners', create: true, owner: 'root', group: 'syslog', mount_options: [ 'share' ]

    if use_db_share == true
      # Map the MySQL Data folders on to mounted folders so it isn't stored inside the VM
      override.vm.synced_folder 'database/data/', '/var/lib/mysql', create: true, owner: 112, group: 115, mount_options: [ 'share' ]
    end

    vvv_config['sites'].each do |site, args|
      next if args['skip_provisioning']
      if args['local_dir'] != File.join(vagrant_dir, 'www', site)
        override.vm.synced_folder args['local_dir'], args['vm_dir'], owner: 'vagrant', group: 'www-data', mount_options: [ 'share' ]
      end
    end
  end

  # The Hyper-V Provider does not understand "dmode"/"fmode" in the "mount_options" as
  # those are specific to Virtualbox. Furthermore, the normal shared folders need to be
  # replaced with SMB shares. Here we switch all the shared folders to us SMB and then
  # override the www folder with options that make it Hyper-V compatible.
  config.vm.provider :hyperv do |v, override|
    v.vmname = File.basename(vagrant_dir) + '_' + (Digest::SHA256.hexdigest vagrant_dir)[0..10]

    override.vm.synced_folder 'www/', '/srv/www', owner: 'vagrant', group: 'www-data', mount_options: ['dir_mode=0775', 'file_mode=0774']

    if use_db_share == true
      # Map the MySQL Data folders on to mounted folders so it isn't stored inside the VM
      override.vm.synced_folder 'database/data/', '/var/lib/mysql', create: true, owner: 112, group: 115, mount_options: ['dir_mode=0775', 'file_mode=0664']
    end

    override.vm.synced_folder 'log/memcached', '/var/log/memcached', owner: 'root', create: true, group: 'syslog', mount_options: ['dir_mode=0777', 'file_mode=0666']
    override.vm.synced_folder 'log/nginx', '/var/log/nginx', owner: 'root', create: true, group: 'syslog', mount_options: ['dir_mode=0777', 'file_mode=0666']
    override.vm.synced_folder 'log/php', '/var/log/php', create: true, owner: 'root', group: 'syslog', mount_options: ['dir_mode=0777', 'file_mode=0666']
    override.vm.synced_folder 'log/provisioners', '/var/log/provisioners', create: true, owner: 'root', group: 'syslog', mount_options: ['dir_mode=0777', 'file_mode=0666']

    vvv_config['sites'].each do |site, args|
      next if args['skip_provisioning']
      if args['local_dir'] != File.join(vagrant_dir, 'www', site)
        override.vm.synced_folder args['local_dir'], args['vm_dir'], owner: 'vagrant', group: 'www-data', mount_options: ['dir_mode=0775', 'file_mode=0774']
      end
    end
  end

  # The VMware Provider does not understand "dmode"/"fmode" in the "mount_options" as
  # those are specific to Virtualbox. The folder is therefore overridden with one that
  # uses corresponding VMware mount options.
  config.vm.provider :vmware_desktop do |_v, override|
    override.vm.synced_folder 'www/', '/srv/www', owner: 'vagrant', group: 'www-data', mount_options: ['umask=002']

    override.vm.synced_folder 'log/memcached', '/var/log/memcached', owner: 'root', create: true, group: 'syslog', mount_options: ['umask=000']
    override.vm.synced_folder 'log/nginx', '/var/log/nginx', owner: 'root', create: true, group: 'syslog', mount_options: ['umask=000']
    override.vm.synced_folder 'log/php', '/var/log/php', create: true, owner: 'root', group: 'syslog', mount_options: ['umask=000']
    override.vm.synced_folder 'log/provisioners', '/var/log/provisioners', create: true, owner: 'root', group: 'syslog', mount_options: ['umask=000']

    if use_db_share == true
      # Map the MySQL Data folders on to mounted folders so it isn't stored inside the VM
      override.vm.synced_folder 'database/data/', '/var/lib/mysql', create: true, owner: 112, group: 115, mount_options: ['umask=000']
    end

    vvv_config['sites'].each do |site, args|
      next if args['skip_provisioning']
      if args['local_dir'] != File.join(vagrant_dir, 'www', site)
        override.vm.synced_folder args['local_dir'], args['vm_dir'], owner: 'vagrant', group: 'www-data', mount_options: ['umask=002']
      end
    end
  end

  # Customfile - POSSIBLY UNSTABLE
  #
  # Use this to insert your own additional Vagrant config lines. Helpful
  # for mapping additional drives. If a file 'Customfile' exists in the same directory
  # as this Vagrantfile, it will be evaluated as ruby inline as it loads.
  #
  # Note that if you find yourself using a Customfile for anything crazy or specifying
  # different provisioning, then you may want to consider a new Vagrantfile entirely.
  if File.exist?(File.join(vagrant_dir, 'Customfile'))
    puts " ⚠ ! Running additional Vagrant code in Customfile located at #{File.join(vagrant_dir, 'Customfile')}\n"
    puts " ⚠ ! Official support is not provided for this feature, it is assumed you are proficient with vagrant\n\n"
    eval(IO.read(File.join(vagrant_dir, 'Customfile')), binding)
    puts " ⚠ ! Finished running Customfile, resuming normal vagrantfile execution\n\n"
  end

  vvv_config['sites'].each do |site, args|
    next unless args['allow_customfile']

    paths = Dir[File.join(args['local_dir'], '**', 'Customfile')]
    paths.each do |file|
      puts " ⚠ ! Running additional site customfile at #{file}\n"
      puts " ⚠ ! Official support is not provided for this feature.\n\n"
      eval(IO.read(file), binding)
      puts " ⚠ ! Finished running Customfile, resuming normal vagrantfile execution\n\n"
    end
  end

  # Provisioning
  #
  # Process one or more provisioning scripts depending on the existence of custom files.

  unless Vagrant::Util::Platform.windows?
    if Process.uid == 0
      # the VM should know if vagrant was ran by a root user or using sudo
      config.vm.provision "flag-root-vagrant-command", type: 'shell', keep_color: true, inline: "mkdir -p /vagrant && touch /vagrant/provisioned_as_root"
    end
  end

  long_provision_bear = <<~HTML
  #{blue}#{creset}
  #{blue}    ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄    ▄   ▄    #{green}A full provision will take a bit.#{creset}
  #{blue}    █▒▒░░░░░░░░░▒▒█   █   █     #{green}Sit back, relax, and have some tea.#{creset}
  #{blue}     █░░█░░░░░█░░█   ▀   ▀      #{creset}
  #{blue}  ▄▄  █░░░▀█▀░░░█   █▀▀▀▀▀▀█    #{green}If you didn't want to provision you can#{creset}
  #{blue} █░░█ ▀▄░░░░░░░▄▀▄▀▀█      █    #{green}turn VVV on with 'vagrant up'.#{creset}
  #{blue}───────────────────────────────────────────────────────────────────────#{creset}
  HTML

  # Changed the message here because it's going to show the first time you do vagrant up, which might be confusing
  config.vm.provision "pre-provision-script", type: 'shell', keep_color: true, inline: "echo \"#{long_provision_bear}\""

  # provison-pre.sh acts as a pre-hook to our default provisioning script. Anything that
  # should run before the shell commands laid out in provision.sh (or your provision-custom.sh
  # file) should go in this script. If it does not exist, no extra provisioning will run.
  if File.exist?(File.join(vagrant_dir, 'provision', 'provision-pre.sh'))
    config.vm.provision 'pre', type: 'shell', keep_color: true, path: File.join('provision', 'provision-pre.sh'), env: { "VVV_LOG" => "pre" }
  end

  # provision.sh or provision-custom.sh
  #
  # By default, Vagrantfile is set to use the provision.sh bash script located in the
  # provision directory. If it is detected that a provision-custom.sh script has been
  # created, that is run as a replacement. This is an opportunity to replace the entirety
  # of the provisioning provided by default.
  if File.exist?(File.join(vagrant_dir, 'provision', 'provision-custom.sh'))
    config.vm.provision 'custom', type: 'shell', keep_color: true, path: File.join('provision', 'provision-custom.sh'), env: { "VVV_LOG" => "main-custom" }
  else
    config.vm.provision 'default', type: 'shell', keep_color: true, path: File.join('provision', 'provision.sh'), env: { "VVV_LOG" => "main" }
  end

  # Provision the dashboard that appears when you visit vvv.test
  config.vm.provision 'dashboard',
                      type: 'shell',
                      keep_color: true,
                      path: File.join('provision', 'provision-dashboard.sh'),
                      args: [
                        vvv_config['dashboard']['repo'],
                        vvv_config['dashboard']['branch']
                      ],
                      env: { "VVV_LOG" => "dashboard" }

  vvv_config['utility-sources'].each do |name, args|
    config.vm.provision "utility-source-#{name}",
                        type: 'shell',
                        keep_color: true,
                        path: File.join('provision', 'provision-utility-source.sh'),
                        args: [
                          name,
                          args['repo'].to_s,
                          args['branch']
                        ],
                        env: { "VVV_LOG" => "utility-source-#{name}" }
  end

  vvv_config['utilities'].each do |name, utilities|
    utilities = {} unless utilities.is_a? Array
    utilities.each do |utility|
      if utility == 'tideways'
        vvv_config['hosts'] += ['tideways.vvv.test']
        vvv_config['hosts'] += ['xhgui.vvv.test']
      end
      config.vm.provision "utility-#{name}-#{utility}",
                          type: 'shell',
                          keep_color: true,
                          path: File.join('provision', 'provision-utility.sh'),
                          args: [
                            name,
                            utility
                          ],
                          env: { "VVV_LOG" => "utility-#{name}-#{utility}" }
    end
  end

  vvv_config['sites'].each do |site, args|
    next if args['skip_provisioning']

    config.vm.provision "site-#{site}",
                        type: 'shell',
                        keep_color: true,
                        path: File.join('provision', 'provision-site.sh'),
                        args: [
                          site,
                          args['repo'].to_s,
                          args['branch'],
                          args['vm_dir'],
                          args['skip_provisioning'].to_s,
                          args['nginx_upstream']
                        ],
                        env: { "VVV_LOG" => "site-#{site}" }
  end

  # provision-post.sh acts as a post-hook to the default provisioning. Anything that should
  # run after the shell commands laid out in provision.sh or provision-custom.sh should be
  # put into this file. This provides a good opportunity to install additional packages
  # without having to replace the entire default provisioning script.
  if File.exist?(File.join(vagrant_dir, 'provision', 'provision-post.sh'))
    config.vm.provision 'post', type: 'shell', keep_color: true, path: File.join('provision', 'provision-post.sh'), env: { "VVV_LOG" => "post" }
  end

  config.vm.provision "post-provision-script", type: 'shell', keep_color: true, path: File.join( 'config/homebin', 'vagrant_provision' ), env: { "VVV_LOG" => "post-provision-script" }

  # Local Machine Hosts
  #
  # If the Vagrant plugin goodhosts (https://github.com/goodhosts/vagrant/) is
  # installed, the following will automatically configure your local machine's hosts file to
  # be aware of the domains specified below. Watch the provisioning script as you may need to
  # enter a password for Vagrant to access your hosts file.
  #
  # By default, we'll include the domains set up by VVV through the vvv-hosts file
  # located in the www/ directory and in config/config.yml.
  #

  if Vagrant.has_plugin?('vagrant-goodhosts')
    config.goodhosts.aliases = vvv_config['hosts']
    config.goodhosts.remove_on_suspend = true
  elsif Vagrant.has_plugin?('vagrant-hostsmanager')
    config.hostmanager.aliases = vvv_config['hosts']
    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
  elsif Vagrant.has_plugin?('vagrant-hostsupdater')
    # Pass the found host names to the hostsupdater plugin so it can perform magic.
    config.hostsupdater.aliases = vvv_config['hosts']
    config.hostsupdater.remove_on_suspend = true
  else
    show_check = true if %w[up halt resume suspend status provision reload].include? ARGV[0]
    if show_check
      puts ""
      puts " X ! There is no hosts file vagrant plugin installed!"
      puts " X You need the vagrant-goodhosts plugin (or HostManager/ HostsUpdater ) for domains to work in the browser"
      puts " X Run 'vagrant plugin install --local' to fix this."
      puts ""
    end
  end

  # Vagrant Triggers
  #
  # We run various scripts on Vagrant state changes like `vagrant up`, `vagrant halt`,
  # `vagrant suspend`, and `vagrant destroy`
  #
  # These scripts are run on the host machine, so we use `vagrant ssh` to tunnel back
  # into the VM and execute things. By default, each of these scripts calls db_backup
  # to create backups of all current databases. This can be overridden with custom
  # scripting. See the individual files in config/homebin/ for details.
  unless Vagrant::Util::Platform.windows?
    if Process.uid == 0
      config.trigger.after :all do |trigger|
        trigger.name = 'Do not use sudo'
        trigger.ruby do |env,machine|
          sudo_warnings
        end
      end
    end
  end

  config.trigger.after :up do |trigger|
    trigger.name = 'VVV Post-Up'
    trigger.run_remote = { inline: '/srv/config/homebin/vagrant_up' }
    trigger.on_error = :continue
  end
  config.trigger.before :reload do |trigger|
    trigger.name = 'VVV Pre-Reload'
    trigger.run_remote = { inline: '/srv/config/homebin/vagrant_halt' }
    trigger.on_error = :continue
  end
  config.trigger.after :reload do |trigger|
    trigger.name = 'VVV Post-Reload'
    trigger.run_remote = { inline: '/srv/config/homebin/vagrant_up' }
    trigger.on_error = :continue
  end
  config.trigger.before :halt do |trigger|
    trigger.name = 'VVV Pre-Halt'
    trigger.run_remote = { inline: '/srv/config/homebin/vagrant_halt' }
    trigger.on_error = :continue
  end
  config.trigger.before :suspend do |trigger|
    trigger.name = 'VVV Pre-Suspend'
    trigger.run_remote = { inline: '/srv/config/homebin/vagrant_suspend' }
    trigger.on_error = :continue
  end
  config.trigger.before :destroy do |trigger|
    trigger.name = 'VVV Pre-Destroy'
    trigger.run_remote = { inline: '/srv/config/homebin/vagrant_destroy' }
    trigger.on_error = :continue
  end
end

vagrant up + halt commands log (RUNNING AS ADMIN)

C:\Users\EUGENY\vvv-local>vagrant up
__ __ __ __
\ V\ V\ V / v3.7.2 Path:"C:/Users/EUGENY/vvv-local"
 \_/\_/\_/  git::stable(92758fd)

Platform: mingw32 windows  HyperV-Admin  HasWinAdminPriv  vagrant-goodhosts vagrant-vbguest monochrome-terminal shared_db_folder_disabled
Vagrant: v2.2.18, hyperv: vn/a

Docs:       https://varyingvagrantvagrants.org/
Contribute: https://github.com/varying-vagrant-vagrants/vvv
Dashboard:  http://vvv.test

Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
==> default: [vagrant-goodhosts] Checking for host entries
==> default: [vagrant-goodhosts] No ip address found for this virtual machine
    default: Configuring the VM...
    default: Setting VM Enhanced session transport type to disabled/default (VMBus)

Vagrant requires administrator access for pruning SMB shares and
may request access to complete removal of stale shares.
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
    default: Timeout: 120 seconds
    default: IP: 172.21.63.233
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 172.21.63.233:22
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
    default: You will be asked for the username and password to use for the SMB
    default: folders shortly. Please use the proper username/password of your
    default: account.
    default:
    default: Username (user[@domain]): tan*****
    default: Password (will be hidden):

Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> default: Setting hostname...
==> default: Mounting SMB shared folders...
    default: C:/Users/EUGENY/vvv-local/database/sql => /srv/database
    default: C:/Users/EUGENY/vvv-local/config => /srv/config
    default: C:/Users/EUGENY/vvv-local/provision => /srv/provision
    default: C:/Users/EUGENY/vvv-local/certificates => /srv/certificates
    default: C:/Users/EUGENY/vvv-local/log/memcached => /var/log/memcached
    default: C:/Users/EUGENY/vvv-local/log/nginx => /var/log/nginx
    default: C:/Users/EUGENY/vvv-local/log/php => /var/log/php
    default: C:/Users/EUGENY/vvv-local/log/provisioners => /var/log/provisioners
    default: C:/Users/EUGENY/vvv-local/www => /srv/www
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running action triggers after up ...
==> default: Running trigger: VVV Post-Up...
    default: Running: inline script
    default:  * Restarting Nginx
    default:  * Restarting MariaDB
    default:  * Syncing clocks
    default: 10 Oct 08:45:57 ntpdate[3250]: adjust time server 91.189.89.198 offset 0.000603 sec
    default:
    default:   ✧ ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄ ✧  Thanks for  __ __ __ __
    default:    ✧█▒▒░░░░░░░░░▒▒█    using       \ V\ V\ V /
    default:  ✧   █░░█░░░░░█░░█ ✧                \_/\_/\_/
    default:   ▄▄  █░░░▀█▀░░░█  ▄▄✧
    default:  █░░█ ▀▄░░░░░░░▄▀ █░░█ Vagrant Up has finished! Visit http://vvv.test
    default: ──────────────────────────────────────────────────────────────────────

C:\Users\EUGENY\vvv-local>vagrant halt
==> default: Running action triggers before halt ...
==> default: Running trigger: VVV Pre-Halt...
    default: Running: inline script
    default:    .  ★         ☁           ★          .
    default: Z        ☽    ★         .        ☁
    default:  Z ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄   ★            __★__ __ __
    default: ☁ z█▒▒░░░░░░░░░▒▒█    Sleep tight \ V\ V\ V /
    default:  ★  █░░▁░░░░░▁░░█  ★               \_/\_/\_/
    default:    . █░░░▀█▀░░░█ .          ★
    default:  ★   ▀▄░░░░░░░▄▀  ★     .
    default:
==> default: [vagrant-goodhosts] Removing hosts
==> default: [vagrant-goodhosts] No ip address found for this virtual machine
==> default: Attempting graceful shutdown of VM...

C:\Users\EUGENY\vvv-local>

what is interesting here is this line: ==> default: [vagrant-goodhosts] No ip address found for this virtual machine it appears on both, up and halt...

any ideas how to make my hosts file updated automagically?

Mte90 commented 3 years ago

So HyperV is a problem as it doesn't set the IP address like the other VM software and when this plugin is executed don't get that, so it is not executed (doesn't happen sometimes like this case). As I am not using Windows I am not able to do a fix for this or find a better way to get that information.

Maybe I should add an alert in the plugin if doesn't detect the IP address and HyperV is used.

tangor86 commented 3 years ago

you can add some output and provide me steps to apply this change and how to test, I will check on my PC and we will see... it you have idea ofc...

Mte90 commented 3 years ago

I have no idea about how to get the IP address with hyperv inside vagrant, as I know with this provider is defined after the execution of vagrant...

Maybe @tomjn has some ideas about it?

tomjn commented 3 years ago

@Mte90 check for it after as well as before provisioning

Mte90 commented 3 years ago

I did a new release with the new code from @tomjn :-)

tangor86 commented 3 years ago

updated plugin but seems no progress, hosts are not updated:

C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>vagrant plugin install --local
Vagrant will now install the following plugins to the local project
which have been defined in current Vagrantfile:

  vagrant-goodhosts (> 0)

Press ctrl-c to cancel...
Installing the 'vagrant-goodhosts' plugin. This can take a few minutes...
Fetching vagrant-goodhosts-1.0.18.gem
Installed the plugin 'vagrant-goodhosts (1.0.18)'!

C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>vagrant up
Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

  vagrant plugin repair

If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:

  vagrant plugin expunge --reinstall

Or you may want to try updating the installed plugins to their latest
versions:

  vagrant plugin update

Error message given during initialization: can't activate vagrant-goodhosts-1.0.17, already activated vagrant-goodhosts-1.0.18

C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>vagrant plugin repair
Repairing currently installed global plugins. This may take a few minutes...
Installed plugins successfully repaired!

C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>vagrant up
Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

  vagrant plugin repair                                                                                                                                                                                                                                                                                                                                               If Vagrant was recently updated, this error may be due to incompatible                                                                                                             versions of dependencies. To fix this problem please remove and re-install                                                                                                         all plugins. Vagrant can attempt to do this automatically by running:                                                                                                              
  vagrant plugin expunge --reinstall

Or you may want to try updating the installed plugins to their latest
versions:

  vagrant plugin update

Error message given during initialization: can't activate vagrant-goodhosts-1.0.17, already activated vagrant-goodhosts-1.0.18

C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>vagrant plugin update
Updating installed plugins...
All plugins are up to date.

C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>vagrant plugin update
Updating installed plugins...
All plugins are up to date.

C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>
C:\Users\EUGENY\vvv-local>vagrant up
__ __ __ __
\ V\ V\ V / v3.7.2 Path:"C:/Users/EUGENY/vvv-local"
 \_/\_/\_/  git::stable(92758fd)

Platform: mingw32 windows  HyperV-Admin  HasWinAdminPriv  vagrant-goodhosts vagrant-vbguest monochrome-terminal shared_db_folder_disabled
Vagrant: v2.2.18, hyperv: vn/a

Docs:       https://varyingvagrantvagrants.org/
Contribute: https://github.com/varying-vagrant-vagrants/vvv
Dashboard:  http://vvv.test

Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
==> default: [vagrant-goodhosts] No ip address found for this virtual machine
    default: Configuring the VM...
    default: Setting VM Enhanced session transport type to disabled/default (VMBus)

Vagrant requires administrator access for pruning SMB shares and
may request access to complete removal of stale shares.
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
    default: Timeout: 120 seconds
    default: IP: 172.21.57.240
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 172.21.57.240:22
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
    default: You will be asked for the username and password to use for the SMB
    default: folders shortly. Please use the proper username/password of your
    default: account.
    default:
    default: Username (user[@domain]): taXXXXXXXXXXXXXXXXXX
    default: Password (will be hidden):

Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> default: Setting hostname...
==> default: Mounting SMB shared folders...
    default: C:/Users/EUGENY/vvv-local/database/sql => /srv/database
    default: C:/Users/EUGENY/vvv-local/config => /srv/config
    default: C:/Users/EUGENY/vvv-local/provision => /srv/provision
    default: C:/Users/EUGENY/vvv-local/certificates => /srv/certificates
    default: C:/Users/EUGENY/vvv-local/log/memcached => /var/log/memcached
    default: C:/Users/EUGENY/vvv-local/log/nginx => /var/log/nginx
    default: C:/Users/EUGENY/vvv-local/log/php => /var/log/php
    default: C:/Users/EUGENY/vvv-local/log/provisioners => /var/log/provisioners
    default: C:/Users/EUGENY/vvv-local/www => /srv/www
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running action triggers after up ...
==> default: Running trigger: VVV Post-Up...
    default: Running: inline script
    default:  * Restarting Nginx
    default:  * Restarting MariaDB
    default:  * Syncing clocks
    default: 11 Oct 16:02:33 ntpdate[3237]: adjust time server 91.189.89.198 offset -0.000610 sec
    default:
    default:   ✧ ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄ ✧  Thanks for  __ __ __ __
    default:    ✧█▒▒░░░░░░░░░▒▒█    using       \ V\ V\ V /
    default:  ✧   █░░█░░░░░█░░█ ✧                \_/\_/\_/
    default:   ▄▄  █░░░▀█▀░░░█  ▄▄✧
    default:  █░░█ ▀▄░░░░░░░▄▀ █░░█ Vagrant Up has finished! Visit http://vvv.test
    default: ──────────────────────────────────────────────────────────────────────

C:\Users\EUGENY\vvv-local>
tomjn commented 3 years ago

Always add —local to plugin commands, otherwise it was a long shot, you’ll need to manually update IPs going forward as this isn’t a trivial fix. It could be months/years before it’s solved for Hyper-V.

As an aside, Hyper-V isn’t necessary for VVV, if you can get away with disabling hyper-v you should. It’s mainly for people who turn on Hyper-V to use docker, but not all windows docker installs use Hyper-V

tangor86 commented 3 years ago

Bringing machine 'default' up with 'virtualbox' provider...
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 vvv.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 one.wordpress.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 two.wordpress.test
==> default: [vagrant-goodhosts] Checking for host entries
Traceback (most recent call last):
        30: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
        29: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `action'
        28: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `call'
        27: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:614:in `lock'
        26: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:215:in `block in action'
        25: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:246:in `action_raw'
        24: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
        23: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
        22: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
        21: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
        20: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        19: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/delayed.rb:19:in `call'
        18: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        17: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/check_virtualbox.rb:26:in `call'
        16: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        15: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/call.rb:43:in `call'
        14: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
        13: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
        12: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
        11: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
        10: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         9: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/created.rb:15:in `call'
         8: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         7: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/commands/up/middleware/store_box_metadata.rb:33:in `call'
         6: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         5: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/Action/BaseAction.rb:31:in `call'
         4: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/Action/UpdateHosts.rb:7:in `run'
         3: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:105:in `addHostEntries'
         2: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:105:in `each'
         1: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:112:in `block in addHostEntries'
C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:128:in `check_hostnames_to_add': undefined method `each' for "vvv.test one.wordpress.test two.wordpress.test":String (NoMethodError)
tangor86 commented 3 years ago

holy smokes! works under virtualbox without any issues! just needed to force 1.0.17 version of this plugin... in the hosts file adds all hosts in one line: 192.168.50.4 vvv.test one.wordpress.test two.wordpress.test mysite.test

P.S: and also performance of the website seems to be better, faster loading...

tangor86 commented 3 years ago

and also doesn't ask for password!

marcagarcia commented 3 years ago
Bringing machine 'default' up with 'virtualbox' provider...
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 vvv.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 one.wordpress.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 two.wordpress.test
==> default: [vagrant-goodhosts] Checking for host entries
Traceback (most recent call last):
        30: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
        29: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `action'
        28: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `call'
        27: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:614:in `lock'
        26: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:215:in `block in action'
        25: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:246:in `action_raw'
        24: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
        23: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
        22: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
        21: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
        20: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        19: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/delayed.rb:19:in `call'
        18: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        17: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/check_virtualbox.rb:26:in `call'
        16: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        15: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/call.rb:43:in `call'
        14: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
        13: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
        12: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
        11: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
        10: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         9: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/created.rb:15:in `call'
         8: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         7: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/commands/up/middleware/store_box_metadata.rb:33:in `call'
         6: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         5: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/Action/BaseAction.rb:31:in `call'
         4: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/Action/UpdateHosts.rb:7:in `run'
         3: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:105:in `addHostEntries'
         2: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:105:in `each'
         1: from C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:112:in `block in addHostEntries'
C:/Users/EUGENY/vvv-local-vb/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.18/lib/vagrant-goodhosts/GoodHosts.rb:128:in `check_hostnames_to_add': undefined method `each' for "vvv.test one.wordpress.test two.wordpress.test":String (NoMethodError)

I also got this bug. check_hostnames_to_add being undefined 1.0.18 https://github.com/goodhosts/vagrant/blob/1.0.18/lib/vagrant-goodhosts/GoodHosts.rb but in Ruby you can't use a function before it's defined maybe? See lines 112 and 124

tomjn commented 3 years ago

@Mte90 did you run my code from the PR or did it get released on just a code review? I hadn't tested any of the code I wrote

tomjn commented 3 years ago

holy smokes! works under virtualbox without any issues! just needed to force 1.0.17 version of this plugin...

@tangor86 unless you disabled Hyper-V explicitly, VirtualBox 6 will lie to you and try to use hyper-v behind the scenes with a compatibility layer. Many users have had issues with that layer. Eitherway try to keep VVV related things in the VVV repo, this issue should justbe for goodhosts and the hosts file additions

Mte90 commented 3 years ago

I released a new version with bugfix for the previous release. Seems that I installed in my local ambient the dev extension but I wasn't using that during the tests -.-'

tangor86 commented 3 years ago
C:\Users\EUGENY\vvv-local>vagrant halt
==> default: Running action triggers before halt ...
==> default: Running trigger: VVV Pre-Halt...
    default: Running: inline script
    default:    .  ★         ☁           ★          .
    default: Z        ☽    ★         .        ☁
    default:  Z ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄   ★            __★__ __ __
    default: ☁ z█▒▒░░░░░░░░░▒▒█    Sleep tight \ V\ V\ V /
    default:  ★  █░░▁░░░░░▁░░█  ★               \_/\_/\_/
    default:    . █░░░▀█▀░░░█ .          ★
    default:  ★   ▀▄░░░░░░░▄▀  ★     .
    default:
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 vvv.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 one.wordpress.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 two.wordpress.test
==> default: [vagrant-goodhosts] Removing hosts
Traceback (most recent call last):
        35: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/bin/vagrant:231:in `<main>'
        34: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:290:in `cli'
        33: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/cli.rb:67:in `execute'
        32: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/commands/halt/command.rb:30:in `execute'
        31: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:232:in `with_target_vms'
        30: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:232:in `each'
        29: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:243:in `block in with_target_vms'
        28: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/commands/halt/command.rb:31:in `block in execute'
        27: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `action'
        26: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `call'
        25: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:614:in `lock'
        24: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:215:in `block in action'
        23: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:246:in `action_raw'
        22: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
        21: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
        20: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
        19: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
        18: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        17: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/trigger.rb:32:in `call'
        16: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        15: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/check_virtualbox.rb:26:in `call'
        14: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
        13: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/call.rb:43:in `call'
        12: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
        11: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
        10: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
         9: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
         8: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         7: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/created.rb:15:in `call'
         6: from D:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
         5: from C:/Users/EUGENY/vvv-local/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/Action/BaseAction.rb:31:in `call'
         4: from C:/Users/EUGENY/vvv-local/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/Action/RemoveHosts.rb:15:in `run'
         3: from C:/Users/EUGENY/vvv-local/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:185:in `removeHostEntries'
         2: from C:/Users/EUGENY/vvv-local/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:185:in `each'
         1: from C:/Users/EUGENY/vvv-local/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:191:in `block in removeHostEntries'
C:/Users/EUGENY/vvv-local/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:159:in `removeGoodhostEntries': undefined local variable or method `cli' for #<VagrantPlugins::GoodHosts::Action::RemoveHosts:0x000001b8d8950398> (NameError)

C:\Users\EUGENY\vvv-local>

guys? :)

tomjn commented 3 years ago

guys

a dangerous assumption!

C:/Users/EUGENY/vvv-local/.vagrant/plugins/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:159:inremoveGoodhostEntries': undefined local variable or method cli' for #<VagrantPlugins::GoodHosts::Action::RemoveHosts:0x000001b8d8950398> (NameError)

WIP

tomjn commented 3 years ago

Also are you sure it's using the latest version when it ran? Globally installed plugins vs locally installated plugins might mean that although you have the new version installed globally, you don't have it installed locally for that project ( installing with --local then forgetting about it is a very common mistake )

tomjn commented 3 years ago

Noting that I ran vagrant plugin update --local and got the .19 version, and it worked fine on an up and a halt

tomjn commented 3 years ago

I managed to reproduce the failure on halt and flushing out .vagrant/plugins so it used the global version:

==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 tomjn.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 multisite-subdir.test
==> default: [vagrant-goodhosts] Removing hosts
Traceback (most recent call last):
    35: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/bin/vagrant:231:in `<main>'
    34: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:290:in `cli'
    33: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/cli.rb:67:in `execute'
    32: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/commands/halt/command.rb:30:in `execute'
    31: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:232:in `with_target_vms'
    30: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:232:in `each'
    29: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:243:in `block in with_target_vms'
    28: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/commands/halt/command.rb:31:in `block in execute'
    27: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `action'
    26: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:201:in `call'
    25: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:614:in `lock'
    24: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:215:in `block in action'
    23: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/machine.rb:246:in `action_raw'
    22: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
    21: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
    20: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
    19: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
    18: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
    17: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/trigger.rb:32:in `call'
    16: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
    15: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/check_virtualbox.rb:26:in `call'
    14: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
    13: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builtin/call.rb:43:in `call'
    12: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `run'
    11: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy'
    10: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/runner.rb:89:in `block in run'
     9: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/builder.rb:149:in `call'
     8: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
     7: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/action/created.rb:15:in `call'
     6: from /opt/vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/action/warden.rb:48:in `call'
     5: from /Users/tarendai/.vagrant.d/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/Action/BaseAction.rb:31:in `call'
     4: from /Users/tarendai/.vagrant.d/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/Action/RemoveHosts.rb:15:in `run'
     3: from /Users/tarendai/.vagrant.d/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:185:in `removeHostEntries'
     2: from /Users/tarendai/.vagrant.d/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:185:in `each'
     1: from /Users/tarendai/.vagrant.d/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:191:in `block in removeHostEntries'
/Users/tarendai/.vagrant.d/gems/2.7.4/gems/vagrant-goodhosts-1.0.19/lib/vagrant-goodhosts/GoodHosts.rb:159:in `removeGoodhostEntries': undefined local variable or method `cli' for #<VagrantPlugins::GoodHosts::Action::RemoveHosts:0x00007fec0a353ce0> (NameError)
tomjn commented 3 years ago

https://github.com/goodhosts/vagrant/pull/42 should fix that issue, the release needs a proper set of testing before a .20 should go out, this would have been caught by verifying the plugin version used via vagrant plugin list --local and an up/halt/up/halt

Mte90 commented 3 years ago

I was thinking to add some tests or linter to avoid those cases that I can't see.

Mte90 commented 3 years ago

I did a new release https://github.com/goodhosts/vagrant/releases/tag/1.1.0beta

It is a beta and a major has includes a refactoring and some code style changes (also the recent fixes). Before to do an official release I prefer to get some testing from everyone :-)

Mte90 commented 3 years ago

You can updates the vagrant plugin and you will have this latest release, let me know if works so I can do an official release.

Download the gem from https://github.com/goodhosts/vagrant/releases/tag/1.1.0beta and next

vagrant plugin install vagrant-goodhosts-1.1.0beta.gem or vagrant plugin --local install vagrant-goodhosts-1.1.0beta.gem to do it

tangor86 commented 3 years ago

updated plugin today to 1.1.0, up and halt seem to work without any issues now, thanks a lot! (with virtualbox as provider)