Skip to content

Commit

Permalink
Make vagrant silently run pxe nodes, without checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeniy L committed Oct 12, 2015
1 parent 5da5f18 commit 39170b3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ SLAVES_CPUS = cfg["slaves_cpus"]
PARAVIRT_PROVIDER = cfg.fetch('paravirtprovider', false)
PREPROVISIONED = cfg.fetch('preprovisioned', true)

# Initialize noop plugins only in case of PXE boot
require_relative 'bootstrap/vagrant_plugins/noop' unless PREPROVISIONED

def ansible_playbook_command(filename, args=[])
"ansible-playbook -v -i \"localhost,\" -c local /vagrant/bootstrap/playbooks/#{filename} #{args.join ' '}"
end
Expand Down Expand Up @@ -118,10 +121,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", inline: slave_celery, privileged: true
config.vm.network "private_network", ip: "10.0.0.#{ip_index}"
else
# Disable attempts to install guest os and check that node is booted using ssh,
# because nodes will have ip addresses from dhcp, and vagrant doesn't know
# which ip to use to perform connection
config.vm.communicator = :noop
config.vm.guest = :noop_guest
# Configure network to boot vm using pxe
config.vm.network "private_network", adapter: 1, ip: "10.0.0.#{ip_index}"
config.vbguest.no_install = true
config.ssh.username = 'root'
config.ssh.insert_key = false
config.vbguest.auto_update = false
end

config.vm.provider :virtualbox do |v|
Expand Down Expand Up @@ -162,6 +170,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

end


def boot_order(virt_config, order)
# Boot order is specified with special flag:
# --boot<1-4> none|floppy|dvd|disk|net
Expand Down
61 changes: 61 additions & 0 deletions bootstrap/vagrant_plugins/noop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Noop Vagrant plugins are used in case if Vagrant does not
# have an access to VMs (e.g. there is no information about ip),
# so it just runs VMs and does not try to perform additional
# actions using SSH.

class NoopCommunicator < Vagrant.plugin("2", :communicator)

def ready?
true
end

def wait_for_ready(timeout)
true
end

end


class NoopGuest < Vagrant.plugin("2", :guest)

def self.change_host_name(*args)
true
end

def self.configure_networks(*args)
true
end

def self.mount_virtualbox_shared_folder(*args)
true
end

end


class NoopCommunicatorPlugin < Vagrant.plugin("2")

name 'Noop communicator/guest'
description 'Noop communicator/guest'

communicator('noop') do
NoopCommunicator
end

guest 'noop_guest' do
NoopGuest
end

guest_capability 'noop_guest', 'change_host_name' do
NoopGuest
end

guest_capability 'noop_guest', 'configure_networks' do
NoopGuest
end

guest_capability 'noop_guest', 'mount_virtualbox_shared_folder' do
NoopGuest
end

end

0 comments on commit 39170b3

Please sign in to comment.