hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.18k stars 4.43k forks source link

Provisioning with Puppet not working correctly. #2134

Closed joegrasse closed 11 years ago

joegrasse commented 11 years ago

With the following config in the vagrantfile provisioning with puppet fails with the following error.

Config: config.vm.provision :puppet do |puppet| puppet.module_path = "modules" end

Error: Shared folders that Puppet requires are missing on the virtual machine. This is usually due to configuration changing after already booting the machine. The fix is to run a vagrant reload so that the proper shared folders will be prepared and mounted on the VM.

Vagrant up output: D:\vagrant\playground>vagrant up --color Bringing machine 'default' up with 'virtualbox' provider... [default] Importing base box 'precise64'... [default] Matching MAC address for NAT networking... [default] Setting the name of the VM... [default] Clearing any previously set forwarded ports... [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Preparing network interfaces based on configuration... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] Running 'pre-boot' VM customizations... [default] Booting VM... [default] Waiting for machine to boot. This may take a few minutes... [default] Machine booted and ready! [default] Mounting shared folders... [default] -- /vagrant [default] -- /tmp/vagrant-puppet/modules-0 [default] -- /tmp/vagrant-puppet/modules-0 [default] Running provisioner: puppet...

Get the same error with the following config as well.

  config.vm.provision :puppet do |puppet|     puppet.module_path = "modules"     puppet.manifests_path = "manifests"     end 

Vagrant v1.3.0

erunion commented 11 years ago

I'm experiencing this as well.

Vagrant.configure("2") do |config|
  config.vm.box = "centos_64_x86_64"
  config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box"
  config.vm.define :platform_site do |t|
    config.vm.provider :virtualbox do |virtualbox|
      virtualbox.customize ["modifyvm", :id, "--memory", "512"]
    end
    config.ssh.forward_agent = true
    config.vm.synced_folder ".", "/var/www"
    config.vm.provision :puppet do |puppet|
      puppet.manifests_path = ".puppet/manifests"
      puppet.manifest_file = "init.pp"
      puppet.module_path = ".puppet/modules"
      puppet.options = ['--verbose']
    end
  end
end
$ vagrant up
Bringing machine 'platform_site' up with 'virtualbox' provider...
[platform_site] Importing base box 'centos_64_x86_64'...
[platform_site] Matching MAC address for NAT networking...
[platform_site] Setting the name of the VM...
[platform_site] Clearing any previously set forwarded ports...
[platform_site] Creating shared folders metadata...
[platform_site] Clearing any previously set network interfaces...
[platform_site] Preparing network interfaces based on configuration...
[platform_site] Forwarding ports...
[platform_site] -- 22 => 2222 (adapter 1)
[platform_site] Running 'pre-boot' VM customizations...
[platform_site] Booting VM...
[platform_site] Waiting for machine to boot. This may take a few minutes...
[platform_site] Machine booted and ready!
[platform_site] Mounting shared folders...
[platform_site] -- /vagrant
[platform_site] -- /var/www
[platform_site] -- /tmp/vagrant-puppet/modules-0
[platform_site] -- /tmp/vagrant-puppet/modules-0
[platform_site] Running provisioner: puppet...
Shared folders that Puppet requires are missing on the virtual machine.
This is usually due to configuration changing after already booting the
machine. The fix is to run a `vagrant reload` so that the proper shared
folders will be prepared and mounted on the VM.

Did not have this issue on v1.2.7

erunion commented 11 years ago

And also after I run vagrant reload, the Puppet provisioner doesn't run.

$ vagrant reload
[platform_site] Attempting graceful shutdown of VM...
[platform_site] Clearing any previously set forwarded ports...
[platform_site] Creating shared folders metadata...
[platform_site] Clearing any previously set network interfaces...
[platform_site] Preparing network interfaces based on configuration...
[platform_site] Forwarding ports...
[platform_site] -- 22 => 2222 (adapter 1)
[platform_site] Running 'pre-boot' VM customizations...
[platform_site] Booting VM...
[platform_site] Waiting for machine to boot. This may take a few minutes...
[platform_site] Machine booted and ready!
[platform_site] Mounting shared folders...
[platform_site] -- /vagrant
[platform_site] -- /var/www
[platform_site] -- /tmp/vagrant-puppet/modules-0
[platform_site] -- /tmp/vagrant-puppet/modules-0
mitchellh commented 11 years ago

Thanks I'm looking into this.

fgrehm commented 11 years ago

@jonursenbach starting with 1.3+ vagrant will not run provisioners after the first up, see https://github.com/mitchellh/vagrant/issues/1776

mitchellh commented 11 years ago

reproduced. fix soon.

erunion commented 11 years ago

@fgrehm I thought that only applied if you were running vagrant up, not vagrant reload.

mitchellh commented 11 years ago

@jonursenbach Both

mitchellh commented 11 years ago

@jonursenbach You now have to specify --provision or run vagrant provision directly.

erunion commented 11 years ago

@mitchellh Ah, interesting. A little confusing, but good to know nonetheless. Thanks.

mitchellh commented 11 years ago

Fixed. This will be in 1.3.1

a-ursino commented 10 years ago

hi i have the same problem too

Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class ntp at /tmp/vagrant-puppet-1/manifests/manifest.pp:9 on node ip-172-31-29-38.eu-west-1.compute.internal
Wrapped exception:
Could not find declared class ntp
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class ntp at /tmp/vagrant-puppet-1/manifests/manifest.pp:9 on node ip-172-31-29-38.eu-west-1.compute.internal
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

FACTER_ssh_username='ubuntu' puppet apply --verbose --hiera_config /vagrant/puphpet/puppet/hiera.yaml --parser future --color=false --manifestdir /tmp/vagrant-puppet-1/manifests --detailed-exitcodes /tmp/vagrant-puppet-1/manifests/manifest.pp || [ $? -eq 2 ]

any advice?

erunion commented 10 years ago

Could not find declared class ntp

Doesn't look like this is a Vagrant issue, but rather with something you're trying to do on line 9 of manifests/manifest.pp.

cdenneen commented 10 years ago

Seeing these reload messages every so often again... did bug get reintroduced?

haf commented 10 years ago

Also getting this with brand new installation from homebrew cask for vagrant and virtualbox.

haf commented 10 years ago

Here's my Vagrantfile, running on OS X 10.9.4:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = 'centos-6.4-x64'
  config.vm.box_url = 'http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20131103.box'
  config.vm.provision "puppet" do |puppet|
    puppet.manifests_path = "manifests"
    puppet.module_path    = "../../puppet/modules"
    puppet.manifest_file  = "site.pp"
    puppet.options = %W[--hiera_config /vagrant/puppet/vagrant_hiera.yaml]
    # Take any FACTER_ prefixed environment variable and set it as a fact for
    # vagrant to give to puppet during provisioning.
    puppet.facter = {}
    ENV.each do |key, value|
      next unless key =~ /^FACTER_/
      puppet.facter[key.gsub(/^FACTER_/, "")] = value
    end
  end
end
$ vagrant up
$ vagrant provision
==> default: Running provisioner: puppet...
Shared folders that Puppet requires are missing on the virtual machine.
This is usually due to configuration changing after already booting the
machine. The fix is to run a `vagrant reload` so that the proper shared
folders will be prepared and mounted on the VM.
$ vagrant version
vagrant version
Installed Version: 1.6.5
Latest Version: 1.6.5

You're running an up-to-date version of Vagrant!
$ uname -a
Darwin coinduction 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
$ vboxmanage --version
4.3.14r95030

Currently verifying guest additions.

--- EDIT:

Still doesn't work after fixing guest additions. It's a real bug.

haf commented 10 years ago

Still doesn't work after fixing guest additions. It's a real bug.

mashpie commented 9 years ago

same here:

added local puppet after fresh vagrant init. the initial vagrant up worked out as expected

==> default: Running provisioner: puppet...
Shared folders that Puppet requires are missing on the virtual machine.
This is usually due to configuration changing after already booting the
machine. The fix is to run a `vagrant reload` so that the proper shared
folders will be prepared and mounted on the VM.
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box                         = "some-box-debian75-in-my-case"
  config.vm.hostname                    = "some-dev"
  config.vm.network                     :private_network, ip: "192.168.3.43"
  config.vm.synced_folder ".", "/vagrant", :nfs => true

  config.vm.provider "vmware_fusion" do |v|
    v.gui = true
    v.vmx["memsize"] = "2048"
    v.vmx["numvcpus"] = "2"
  end

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file  = "prepare-puppetserver.pp"
    puppet.module_path = "puppet/modules"
    puppet.options = ["--fileserverconfig=/vagrant/puppet/fileserver.conf", ]
  end

end
.
..
Vagrantfile
puppet
├── files
│   ├── hiera.yaml
│   └── ssl
│       ├── certificate_requests
│       │   └── some-dev.pem
│       ├── certs
│       │   ├── ca.pem
│       │   └── some-dev.pem
│       ├── crl.pem
│       ├── private
│       ├── private_keys
│       │   └── some-dev.pem
│       └── public_keys
│           └── some-dev.pem
├── fileserver.conf
├── manifests
│   └── prepare-puppetserver.pp
└── modules

complain: ON this is 3rd issue after upgrade to 1.6.5 & Fusion7. Had to start with fresh boxes (yes, I ran guest updates without luck), disabled HGFS Mounts (or changed to NFS), lot's of reboots to mitigate vmnet conflicts, etc. etc.

We've switched to Fusion to mitigate VirtualBox Issues before - and yes, we love(d) vagrant + VMWare. This is the 1st time I'm stuck - had to happen some time, but would be worth to avoid. complain: OFF

Am I missing something? Anything I could do to help fixing?

kikitux commented 9 years ago

try:

vagrant reload --provision

On Sat, Sep 20, 2014 at 8:40 AM, Marcus Spiegel notifications@github.com wrote:

same here:

  • OSX 10.9.4
  • vagrant 1.6.5
  • VMWare Fusion 7
  • /vagrant is mounted inside VM

added local puppet after fresh vagrant init. the initial vagrant up worked out as expected

==> default: Running provisioner: puppet... Shared folders that Puppet requires are missing on the virtual machine. This is usually due to configuration changing after already booting the machine. The fix is to run a vagrant reload so that the proper shared folders will be prepared and mounted on the VM.

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.box = "some-box-debian75-in-my-case" config.vm.hostname = "some-dev" config.vm.network :private_network, ip: "192.168.3.43" config.vm.synced_folder ".", "/vagrant", :nfs => true

config.vm.provider "vmware_fusion" do |v| v.gui = true v.vmx["memsize"] = "2048" v.vmx["numvcpus"] = "2" end

config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "prepare-puppetserver.pp" puppet.module_path = "puppet/modules" puppet.options = ["--fileserverconfig=/vagrant/puppet/fileserver.conf", ] end end

. .. Vagrantfile puppet ├── files │ ├── hiera.yaml │ └── ssl │ ├── certificate_requests │ │ └── some-dev.pem │ ├── certs │ │ ├── ca.pem │ │ └── some-dev.pem │ ├── crl.pem │ ├── private │ ├── private_keys │ │ └── some-dev.pem │ └── public_keys │ └── some-dev.pem ├── fileserver.conf ├── manifests │ └── prepare-puppetserver.pp └── modules

complain: ON this is 3rd issue after upgrade to Fusion7. Had to start with fresh boxes (yes, I ran guest updates without luck), disabled HGFS Mounts (or changed to NFS), lot's of reboots to mitigate vmnet conflicts, etc. etc.

We've switch to Fusion to mitigate VirtualBox Issues before - and yes, we love(d) vagrant + VMWare. This is the 1st time I'm stuck - had to happen some time, but would be worth to avoid. complain: OFF

Am I missing something? Anything I could do to help fixing?

— Reply to this email directly or view it on GitHub https://github.com/mitchellh/vagrant/issues/2134#issuecomment-56232564.

mashpie commented 9 years ago

I did try any combination of these in sequence:

without luck... fun thing: sometimes it works, most times not and VM hangs at one of those steps:

even after reboot of os x. Behaviour is not predictable.

mobil beantwortet

Am 22.09.2014 um 03:34 schrieb Alvaro Miranda notifications@github.com:

try:

vagrant reload --provision

On Sat, Sep 20, 2014 at 8:40 AM, Marcus Spiegel notifications@github.com wrote:

same here:

  • OSX 10.9.4
  • vagrant 1.6.5
  • VMWare Fusion 7
  • /vagrant is mounted inside VM

added local puppet after fresh vagrant init. the initial vagrant up worked out as expected

==> default: Running provisioner: puppet... Shared folders that Puppet requires are missing on the virtual machine. This is usually due to configuration changing after already booting the machine. The fix is to run a vagrant reload so that the proper shared folders will be prepared and mounted on the VM.

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.box = "some-box-debian75-in-my-case" config.vm.hostname = "some-dev" config.vm.network :private_network, ip: "192.168.3.43" config.vm.synced_folder ".", "/vagrant", :nfs => true

config.vm.provider "vmware_fusion" do |v| v.gui = true v.vmx["memsize"] = "2048" v.vmx["numvcpus"] = "2" end

config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "prepare-puppetserver.pp" puppet.module_path = "puppet/modules" puppet.options = ["--fileserverconfig=/vagrant/puppet/fileserver.conf", ] end end

. .. Vagrantfile puppet ├── files │ ├── hiera.yaml │ └── ssl │ ├── certificate_requests │ │ └── some-dev.pem │ ├── certs │ │ ├── ca.pem │ │ └── some-dev.pem │ ├── crl.pem │ ├── private │ ├── private_keys │ │ └── some-dev.pem │ └── public_keys │ └── some-dev.pem ├── fileserver.conf ├── manifests │ └── prepare-puppetserver.pp └── modules

complain: ON this is 3rd issue after upgrade to Fusion7. Had to start with fresh boxes (yes, I ran guest updates without luck), disabled HGFS Mounts (or changed to NFS), lot's of reboots to mitigate vmnet conflicts, etc. etc.

We've switch to Fusion to mitigate VirtualBox Issues before - and yes, we love(d) vagrant + VMWare. This is the 1st time I'm stuck - had to happen some time, but would be worth to avoid. complain: OFF

Am I missing something? Anything I could do to help fixing?

— Reply to this email directly or view it on GitHub https://github.com/mitchellh/vagrant/issues/2134#issuecomment-56232564.

— Reply to this email directly or view it on GitHub.

mashpie commented 9 years ago

Ok, got puppet provision working thru NFS mounts:

  config.vm.provision "puppet" do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file  = "prepare-puppetserver.pp"
    puppet.synced_folder_type = "nfs"
    puppet.module_path = "puppet/modules"
    puppet.options = ["--fileserverconfig=/vagrant/puppet/fileserver.conf", ]
  end

the important part ist: puppet.synced_folder_type = "nfs"

...still vmnet issues remain "The VMware "vmnet" devices are failing to start", which in turn block any nfs mount

bdgeorge commented 9 years ago

I'm finding the same thing even with nfs mounts, has it continued to work for you?

mashpie commented 9 years ago

well sometimes I need to vagrant reload my boxes 2..3 times until they get connected. This helps, although needs to get fixed. But as I we have to finish those projects we won't experiment with any further updates :)

l0b0 commented 9 years ago

Since relatively recently (certainly within the last month) this reliably doesn't work anymore on Arch Linux with up-to-date packages:

$ /usr/bin/vagrant destroy --force
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
==> default: Running cleanup tasks for 'shell' provisioner...
==> default: Running cleanup tasks for 'puppet' provisioner...
$ /usr/bin/vagrant up --no-provision
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'terrywang/archlinux'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'terrywang/archlinux' is up to date...
==> default: Setting the name of the VM: root_default_1419262938589_18036
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if its present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/victor/dev/root
    default: /tmp/vagrant-puppet-4/manifests => /home/victor/dev/root/manifests
    default: /tmp/vagrant-puppet-4/modules-0 => /home/victor/dev/root/modules
==> default: Machine not provisioning because `--no-provision` is specified.
/usr/bin/vagrant provision || [ $? -eq 2 ]
==> default: Running provisioner: shell...
    default: Running: /tmp/vagrant-shell20141222-15723-gxh1y8.sh
[...]
==> default: Running provisioner: puppet...
Shared folders that Puppet requires are missing on the virtual machine.
This is usually due to configuration changing after already booting the
machine. The fix is to run a `vagrant reload` so that the proper shared
folders will be prepared and mounted on the VM.

Workaround: Don't use --no-provision, which means a new VM will be double provisioned (the second provisioning breaks with the same error as above), or always destroy the VM before running vagrant up, which takes longer than reusing an existing VM.

If anyone can make the same code work (the commands are in the test Makefile target) without double provisioning that would be great.