Skip to content

Instantly share code, notes, and snippets.

@harobed
Created February 16, 2017 10:35
Show Gist options
  • Save harobed/f3198e47417b026969fcae99b6cef39d to your computer and use it in GitHub Desktop.
Save harobed/f3198e47417b026969fcae99b6cef39d to your computer and use it in GitHub Desktop.
macbook:vagrant stephane$ vagrant up
Bringing machine 'master' up with 'virtualbox' provider...
==> master: Importing base box 'centos/atomic-host'...
==> master: Matching MAC address for NAT networking...
==> master: Setting the name of the VM: vagrant_master_1487241098113_50541
==> master: Clearing any previously set network interfaces...
==> master: Preparing network interfaces based on configuration...
master: Adapter 1: nat
master: Adapter 2: hostonly
==> master: Forwarding ports...
master: 22 (guest) => 2222 (host) (adapter 1)
==> master: Booting VM...
==> master: Waiting for machine to boot. This may take a few minutes...
master: SSH address: 127.0.0.1:2222
master: SSH username: vagrant
master: SSH auth method: private key
master:
master: Vagrant insecure key detected. Vagrant will automatically replace
master: this with a newly generated keypair for better security.
master:
master: Inserting generated public key within guest...
master: Removing insecure key from the guest if it's present...
master: Key inserted! Disconnecting and reconnecting using new SSH key...
==> master: Machine booted and ready!
==> master: Checking for guest additions in VM...
master: No guest additions were detected on the base box for this VM! Guest
master: additions are required for forwarded ports, shared folders, host only
master: networking, and more. If SSH fails on this machine, please install
master: the guest additions and repackage the box to continue.
master:
master: This is not an error message; everything may continue to work properly,
master: in which case you may ignore this message.
==> master: Setting hostname...
==> master: Configuring and enabling network interfaces...
==> master: Updating /etc/hosts file on active guest machines...
==> master: Forcing shutdown of VM...
==> master: Destroying VM and associated drives...
/Users/stephane/projets/openshift/ta-ansible/vagrant/Vagrantfile:24:in `read_ip_address': undefined method `info' for nil:NilClass (NoMethodError)
from /Users/stephane/projets/openshift/ta-ansible/vagrant/Vagrantfile:43:in `block (2 levels) in <top (required)>'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:106:in `call'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:106:in `get_ip_address'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:95:in `get_hosts_file_entry'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:89:in `block in update_content'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:89:in `map'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:89:in `update_content'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:79:in `update_file'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/hosts_file/updater.rb:38:in `update_guest'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/action/update_all.rb:37:in `block in call'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/action/update_all.rb:32:in `each'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-hostmanager-1.8.5/lib/vagrant-hostmanager/action/update_all.rb:32:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/provision.rb:80:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/clear_forwarded_ports.rb:15:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/set_name.rb:50:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/clean_machine_folder.rb:17:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/call.rb:53:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/call.rb:53:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/call.rb:53:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/box_check_outdated.rb:23:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/match_mac_address.rb:19:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/discard_state.rb:15:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/import.rb:74:in `import'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/import.rb:13:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb:17:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/prepare_clone.rb:15:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/customize.rb:40:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/call.rb:53:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/call.rb:53:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-triggers-0.5.3/lib/vagrant-triggers/action/trigger.rb:17:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-triggers-0.5.3/lib/vagrant-triggers/action/trigger.rb:17:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /Users/stephane/.vagrant.d/gems/2.2.5/gems/vagrant-triggers-0.5.3/lib/vagrant-triggers/action/trigger.rb:17:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:225:in `action_raw'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:200:in `block in action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/environment.rb:567:in `lock'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:186:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:186:in `action'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
config.hostmanager.include_offline = true
def read_ip_address(machine)
command = "ip a | grep 'inet' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $2 }' | cut -f1 -d\"/\""
result = ""
$logger.info "Processing #{ machine.name } ... "
begin
# sudo is needed for ifconfig
machine.communicate.sudo(command) do |type, data|
result << data if type == :stdout
end
$logger.info "Processing #{ machine.name } ... success"
rescue
result = "# NOT-UP"
$logger.info "Processing #{ machine.name } ... not running"
end
# the second inet is more accurate
result.chomp.split("\n").last
end
if Vagrant.has_plugin?("HostManager")
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
read_ip_address(vm)
end
end
config.vm.define "master" do |server|
server.vm.hostname = "master.os.example.com"
server.vm.box = "centos/atomic-host"
server.vm.box_check_update = false
server.vm.network "private_network", type: "dhcp"
server.vm.synced_folder '.', '/home/vagrant/sync', disabled: true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment