New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaged puppet manifest, vagrantfile, and modules not copied on vagrant init #344

Closed
crohr opened this Issue Apr 16, 2011 · 7 comments

Comments

Projects
None yet
6 participants
@crohr

crohr commented Apr 16, 2011

Hi,

Maybe it's me, but when you package puppet manifests and modules in a new base box with:

vagrant package --base centos-x64 --vagrantfile Vagrantfile --include manifests/ modules/

then:

vagrant box add centos5-x64 package.box

and:

mkdir whatever && cd whatever/
vagrant init centos5-x64

A default Vagranfile is generated, and when I try to do a vagrant up it fails saying it cannot find the manifests nor the modules:

vm:
* The manifests path specified for Puppet does not exist: /Volumes/backup/dev/boxes/whatever/manifests
* The configured module path doesn't exist: /Volumes/backup/dev/boxes/whatever/modules

I can see that my included files have been correctly extracted to ~/.vagrant/boxes/centos5-x64/include/ (on vagrant add), but I don't understand how I can correctly initialize that box. Am I doing something wrong? I thought the included files would be copied in my whatever directory on vagrant init centos5-x64 command.

@ghost ghost assigned mitchellh Apr 20, 2011

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Apr 20, 2011

Member

Crohr,

Ah, so this is a common misconception, but you're about halfway right :) Files that are included with the boxes aren't unpacked into the project directory during a vagrant init. But they are available in the box itself. Could you show me your Vagrantfile? (that is packaged with the box) I should be able to help you properly reference the modules and manifests you need.

Best,
Mitchell

Member

mitchellh commented Apr 20, 2011

Crohr,

Ah, so this is a common misconception, but you're about halfway right :) Files that are included with the boxes aren't unpacked into the project directory during a vagrant init. But they are available in the box itself. Could you show me your Vagrantfile? (that is packaged with the box) I should be able to help you properly reference the modules and manifests you need.

Best,
Mitchell

@crohr

This comment has been minimized.

Show comment
Hide comment
@crohr

crohr Apr 20, 2011

Thanks for your answer, here is the Vagrantifle included in the box:

Vagrant::Config.run do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "centos5-x64"

  # The url from where the 'config.vm.box' box will be fetched if it
  # doesn't already exist on the user's system.
  # config.vm.box_url = "http://domain.com/path/to/above.box"

  # Boot with a GUI so you can see the screen. (Default is headless)
  # config.vm.boot_mode = :gui

  # Assign this VM to a host only network IP, allowing you to access it
  # via the IP.
  # config.vm.network "33.33.33.10"

  # Forward a port from the guest to the host, which allows for outside
  # computers to access the VM, whereas host only networking does not.
  config.vm.forward_port "ldap", 389, 1389
  config.vm.forward_port "http", 8000, 8000

  # Share an additional folder to the guest VM. The first argument is
  # an identifier, the second is the path on the guest to mount the
  # folder, and the third is the path on the host to the actual folder.
  # config.vm.share_folder "v-data", "/vagrant_data", "../data"

  # Enable provisioning with chef solo, specifying a cookbooks path (relative
  # to this Vagrantfile), and adding some recipes and/or roles.
  config.vm.provision :puppet, :module_path => "./modules"

end

crohr commented Apr 20, 2011

Thanks for your answer, here is the Vagrantifle included in the box:

Vagrant::Config.run do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "centos5-x64"

  # The url from where the 'config.vm.box' box will be fetched if it
  # doesn't already exist on the user's system.
  # config.vm.box_url = "http://domain.com/path/to/above.box"

  # Boot with a GUI so you can see the screen. (Default is headless)
  # config.vm.boot_mode = :gui

  # Assign this VM to a host only network IP, allowing you to access it
  # via the IP.
  # config.vm.network "33.33.33.10"

  # Forward a port from the guest to the host, which allows for outside
  # computers to access the VM, whereas host only networking does not.
  config.vm.forward_port "ldap", 389, 1389
  config.vm.forward_port "http", 8000, 8000

  # Share an additional folder to the guest VM. The first argument is
  # an identifier, the second is the path on the guest to mount the
  # folder, and the third is the path on the host to the actual folder.
  # config.vm.share_folder "v-data", "/vagrant_data", "../data"

  # Enable provisioning with chef solo, specifying a cookbooks path (relative
  # to this Vagrantfile), and adding some recipes and/or roles.
  config.vm.provision :puppet, :module_path => "./modules"

end
@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh May 12, 2011

Member

Sorry I took so long to respond. So what you want to change, this will be slightly confusing, sorry, but:

config.vm.provision :puppet, :module_path => File.expand_path("../modules", __FILE__)

The reasoning for this is that this will get the modules directory relative to the packaged Vagrantfile, rather than the Vagrant environment.

I'm looking into a better way to do this.

Member

mitchellh commented May 12, 2011

Sorry I took so long to respond. So what you want to change, this will be slightly confusing, sorry, but:

config.vm.provision :puppet, :module_path => File.expand_path("../modules", __FILE__)

The reasoning for this is that this will get the modules directory relative to the packaged Vagrantfile, rather than the Vagrant environment.

I'm looking into a better way to do this.

@mitchellh mitchellh closed this May 12, 2011

@oker1

This comment has been minimized.

Show comment
Hide comment
@oker1

oker1 Sep 25, 2011

Contributor

I think this tip could be in the documentation until a better solution is available.

Contributor

oker1 commented Sep 25, 2011

I think this tip could be in the documentation until a better solution is available.

@astrostl

This comment has been minimized.

Show comment
Hide comment
@astrostl

astrostl Apr 9, 2012

Contributor

Agreed on docs.

Contributor

astrostl commented Apr 9, 2012

Agreed on docs.

@delitescere

This comment has been minimized.

Show comment
Hide comment
@delitescere

delitescere Feb 18, 2015

Just an idea, the "better way to do this" is for Vagrant to automatically provide access to the include files via the /vagrant share.

I'm hacking it like this in my packaged Vagrantfile (the _Vagrantfile in the box):

config.vm.synced_folder File.expand_path("../", __FILE__), "/vagrant/include" # get the box "include" files into the VM

delitescere commented Feb 18, 2015

Just an idea, the "better way to do this" is for Vagrant to automatically provide access to the include files via the /vagrant share.

I'm hacking it like this in my packaged Vagrantfile (the _Vagrantfile in the box):

config.vm.synced_folder File.expand_path("../", __FILE__), "/vagrant/include" # get the box "include" files into the VM
@richard-mauri

This comment has been minimized.

Show comment
Hide comment
@richard-mauri

richard-mauri Jan 27, 2016

So "vagrant init" will not extract the Vagrantfile that I had packer include in the box?
My Vagrantfile has a lot of important settings that must be in the local Vagrantfile in order for the vagrant up/ssh dance to work correctly. Must I invent some ad-hoc mechanism to download a Vagrantfile that will work with my box?

My Vagrantfile looks like the following (sorry that there is strange formatting/markdown):


-- mode: ruby --

vi: set ft=ruby :

All Vagrant configuration is done below. The "2" in Vagrant.configure

configures the configuration version (we support older styles for

backwards compatibility). Please don't change it unless you know what

you're doing.

required_plugins = %w(vagrant-vbguest vagrant-cachier vagrant-proxyconf)

plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
puts "Installing plugins: #{plugins_to_install.join(' ')}"
if system "vagrant plugin install #{plugins_to_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
else
abort "Installation of one or more plugins has failed. Aborting."
end
end

$script = <<SCRIPT
sleep 10
SCRIPT

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu-14.04.3-cobaltbasedev"
config.vm.box_url = "https://registry.mo.sap.corp:443/vagrant-dev-local/ubuntu-14.04.3-cobaltbasedev.box"
config.vbguest.auto_update = false
config.vm.box_download_insecure = true
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.provider :virtualbox do |p|
p.customize ["modifyvm", :id, "--memory", 1024]
p.customize ["modifyvm", :id, "--cpus", 2]
p.customize ["modifyvm", :id, "--cpuexecutioncap", 50]
p.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end

# Sync up the project folder from laptop host
config.vm.synced_folder ".", "/home/vagrant/SampleApp"

# We can enable this later on, if required
config.vm.box_check_update = false

# Give a host name
config.vm.hostname = "ubuntu-14.04.3-cobaltbasedev"
config.vm.network "private_network", ip: "10.100.192.200"

# Configure network
#config.vm.network "forwarded_port", guest: 80, host: 8000

##Consul tunnel from laptop to vagrant vm @ http://localhost:8500/ui
config.vm.network :forwarded_port, guest: 8500, guest_ip:"10.0.2.15", host: 8500, host_ip:"0.0.0.0"

##Sample App tunnel from laptop to vagrant vm @ http://localhost:8080/greeting
config.vm.network :forwarded_port, guest: 8000, guest_ip:"10.0.2.15", host: 8080, host_ip:"0.0.0.0"

##Nginx tunnel from latop to vagrant vm @ http://localhost:8090/greeting
config.vm.network :forwarded_port, guest: 8090, guest_ip:"10.0.2.15", host: 8090, host_ip:"0.0.0.0"

# Configure Private Registry for docker to make use to get binaries from Artifactory
#config.vm.provision :shell, path: "scripts/ubuntu/config-private-registry.sh"

# Change consul configuration
#config.vm.provision :shell, path: "scripts/ubuntu/config-consul.sh"

# Configure Docker for Ubuntu
config.vm.provision :shell, inline: "sudo service docker stop", :privileged => true
config.vm.provision "shell", inline: $script
config.vm.provision :shell do |sh|
    sh.inline = <<-EOT
        sudo echo 'DOCKER_OPTS="-D --selinux-enabled --registry-mirror=https://registry.mo.sap.corp:5000 --cluster-store=consul://10.0.2.15:8500 --cluster-advertise=eth1:0"' > /etc/default/docker
    EOT
end
config.vm.provision :shell, inline: "sudo service docker start", :privileged => true

#create a pod overlay network
config.vm.provision :shell, inline: "docker network create -d overlay pod-network"

#bootstrap a key/value structure for sample app to poll
config.vm.provision :shell, inline: "curl -X PUT -d 'demo-sample-app' http://127.0.0.1:8500/v1/kv/sample-app/greeting"

#build docker images and boostrap containers:  consul client and nginx
#config.vm.provision "docker" do |d|
#    d.build_image "/home/vagrant/SampleApp/nginx", args: "-t load-balance-nginx"
#    d.run "consul", auto_assign_name: true, daemonize: true, args: "--net pod-network  progrium/consul -advertise 127.0.0.1 -join 10.0.2.15"
#    d.run "load-balance-nginx", auto_assign_name: true, daemonize: true, args: "-p 8090:80 --net pod-network"
#end

config.vm.provision "shell", privileged: false, inline: <<-EOF
    echo "Vagrant Box provisioned!"
    echo "Consul UI can be accessed from your desktop using:  http://localhost:8500/ui"
    #echo "NGINX can be accessed from your desktop using:  http://localhost:8090/health.txt"
    #echo "SAMPLE APP can be accessed from your desktop using:  http://localhost:8090/sample-app/greeting"
EOF

end

richard-mauri commented Jan 27, 2016

So "vagrant init" will not extract the Vagrantfile that I had packer include in the box?
My Vagrantfile has a lot of important settings that must be in the local Vagrantfile in order for the vagrant up/ssh dance to work correctly. Must I invent some ad-hoc mechanism to download a Vagrantfile that will work with my box?

My Vagrantfile looks like the following (sorry that there is strange formatting/markdown):


-- mode: ruby --

vi: set ft=ruby :

All Vagrant configuration is done below. The "2" in Vagrant.configure

configures the configuration version (we support older styles for

backwards compatibility). Please don't change it unless you know what

you're doing.

required_plugins = %w(vagrant-vbguest vagrant-cachier vagrant-proxyconf)

plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
puts "Installing plugins: #{plugins_to_install.join(' ')}"
if system "vagrant plugin install #{plugins_to_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
else
abort "Installation of one or more plugins has failed. Aborting."
end
end

$script = <<SCRIPT
sleep 10
SCRIPT

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu-14.04.3-cobaltbasedev"
config.vm.box_url = "https://registry.mo.sap.corp:443/vagrant-dev-local/ubuntu-14.04.3-cobaltbasedev.box"
config.vbguest.auto_update = false
config.vm.box_download_insecure = true
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.provider :virtualbox do |p|
p.customize ["modifyvm", :id, "--memory", 1024]
p.customize ["modifyvm", :id, "--cpus", 2]
p.customize ["modifyvm", :id, "--cpuexecutioncap", 50]
p.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end

# Sync up the project folder from laptop host
config.vm.synced_folder ".", "/home/vagrant/SampleApp"

# We can enable this later on, if required
config.vm.box_check_update = false

# Give a host name
config.vm.hostname = "ubuntu-14.04.3-cobaltbasedev"
config.vm.network "private_network", ip: "10.100.192.200"

# Configure network
#config.vm.network "forwarded_port", guest: 80, host: 8000

##Consul tunnel from laptop to vagrant vm @ http://localhost:8500/ui
config.vm.network :forwarded_port, guest: 8500, guest_ip:"10.0.2.15", host: 8500, host_ip:"0.0.0.0"

##Sample App tunnel from laptop to vagrant vm @ http://localhost:8080/greeting
config.vm.network :forwarded_port, guest: 8000, guest_ip:"10.0.2.15", host: 8080, host_ip:"0.0.0.0"

##Nginx tunnel from latop to vagrant vm @ http://localhost:8090/greeting
config.vm.network :forwarded_port, guest: 8090, guest_ip:"10.0.2.15", host: 8090, host_ip:"0.0.0.0"

# Configure Private Registry for docker to make use to get binaries from Artifactory
#config.vm.provision :shell, path: "scripts/ubuntu/config-private-registry.sh"

# Change consul configuration
#config.vm.provision :shell, path: "scripts/ubuntu/config-consul.sh"

# Configure Docker for Ubuntu
config.vm.provision :shell, inline: "sudo service docker stop", :privileged => true
config.vm.provision "shell", inline: $script
config.vm.provision :shell do |sh|
    sh.inline = <<-EOT
        sudo echo 'DOCKER_OPTS="-D --selinux-enabled --registry-mirror=https://registry.mo.sap.corp:5000 --cluster-store=consul://10.0.2.15:8500 --cluster-advertise=eth1:0"' > /etc/default/docker
    EOT
end
config.vm.provision :shell, inline: "sudo service docker start", :privileged => true

#create a pod overlay network
config.vm.provision :shell, inline: "docker network create -d overlay pod-network"

#bootstrap a key/value structure for sample app to poll
config.vm.provision :shell, inline: "curl -X PUT -d 'demo-sample-app' http://127.0.0.1:8500/v1/kv/sample-app/greeting"

#build docker images and boostrap containers:  consul client and nginx
#config.vm.provision "docker" do |d|
#    d.build_image "/home/vagrant/SampleApp/nginx", args: "-t load-balance-nginx"
#    d.run "consul", auto_assign_name: true, daemonize: true, args: "--net pod-network  progrium/consul -advertise 127.0.0.1 -join 10.0.2.15"
#    d.run "load-balance-nginx", auto_assign_name: true, daemonize: true, args: "-p 8090:80 --net pod-network"
#end

config.vm.provision "shell", privileged: false, inline: <<-EOF
    echo "Vagrant Box provisioned!"
    echo "Consul UI can be accessed from your desktop using:  http://localhost:8500/ui"
    #echo "NGINX can be accessed from your desktop using:  http://localhost:8090/health.txt"
    #echo "SAMPLE APP can be accessed from your desktop using:  http://localhost:8090/sample-app/greeting"
EOF

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment