Vagrant: Unable to run Puppet provisioner on 2.0.4

Created on 23 Apr 2018  ยท  6Comments  ยท  Source: hashicorp/vagrant

Please note that the Vagrant issue tracker is reserved for bug reports and
enhancements. For general usage questions, please use the Vagrant mailing list:
https://groups.google.com/forum/#!forum/vagrant-up. Thank you!

Vagrant version

2.0.4

Host operating system

MacOS 10.13.4

Guest operating system

Ubuntu 16.04

Vagrantfile

# Note: much of the documentation and code in this file is from Varying Vagrant Vagrants, the original base for this project

vagrant_dir = File.expand_path(File.dirname(__FILE__))

Vagrant.configure("2") do |root|
    root.vm.define 'Ouroboros' 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/, '')

        # Default Ubuntu Box
        #
        # This box is provided directly by Bento and is updated regularly.
        config.vm.box = "bento/ubuntu-16.04"

        config.vm.hostname = "ouro"

        # Default Box IP Address
        #
        # This is the IP address that your host will communicate to the guest through. In the
        # case of the default `192.168.56.101` that we've provided, Virtualbox will setup another
        # network adapter on your host machine with the IP `192.168.22.1` as a gateway.
        #
        # If you are already on a network using the 192.168.22.x subnet, this should be changed.
        # If you are running more than one VM through Virtualbox, different subnets should be used
        # for those as well. This includes other Vagrant boxes.
        machineIP = '192.168.22.101'

        config.vm.network :private_network, id: "ouro_primary", ip: machineIP

        # Local Machine Hosts
        #
        # If the Vagrant plugin Ghost (https://github.com/10up/vagrant-ghost) 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 Primary Vagrant through the ouro-hosts file
        # located in the default-sites/ directory.
        #
        # Other domains can be automatically added by including a ouro-hosts file containing
        # individual domains separated by whitespace in subdirectories of user-data/ and user-date/sites/.
        unless Vagrant.has_plugin?("landrush")

            if defined?(VagrantPlugins::Ghost)
                # Recursively fetch the paths to all ouro-hosts files under the default-sites/, user-data/ and user-data/sites/ directories.
                paths = Dir[File.join(vagrant_dir, 'default-sites', 'ouro-hosts')] + Dir[File.join(vagrant_dir, 'user-data', 'ouro-hosts')]+ Dir[File.join(vagrant_dir, 'user-data', 'sites', '**', 'ouro-hosts')]

                # Parse the found ouro-hosts files for host names.
                hosts = paths.map do |path|

                # Read line from file and remove line breaks
                lines = File.readlines(path).map(&:chomp)

                # Filter out comments starting with "#"
                lines.grep(/\A[^#]/)

                end.flatten.uniq # Remove duplicate entries

                # Pass the found host names to the ghost plugin so it can perform magic.
                config.ghost.hosts = hosts
            end
        end

        # If We have Landrush use it to set the toplevel to pv.
        # The use of landrush will override all custom domains set and all sites and projects will simply revert to the "pv" toplevel.
        if Vagrant.has_plugin?("landrush")

            config.landrush.enabled = true

            config.landrush.tld = 'ouro'

        end

        # Forward Agent
        #
        # Enable agent forwarding on vagrant ssh commands. This allows you to use identities
        # established on the host machine inside the guest. See the manual for ssh-add
        config.ssh.forward_agent = true

        # 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, "--natdnshostresolver1", "on"]
            v.customize ["modifyvm", :id, "--memory", 1024]
            v.customize ["modifyvm", :id, "--name", "Ouroboros"]
            v.customize ["modifyvm", :id, "--cpus", 1]
            v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]

            # set auto_update to false, if you do NOT want to check the correct
            # additions version when booting this machine
            if Vagrant.has_plugin?("vagrant-vbguest")
                config.vbguest.auto_update = true
            end
        end

        # Don't check for updates with every vagrant up
        config.vm.box_check_update = false

        # Drive mapping
        #
        # The following config.vm.share_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.

        # Custom Mappings
        #
        # Use this to insert your own (and possibly rewrite) Vagrant config lines. Helpful
        # for mapping additional drives. If a file 'ouro-mappings' exists in the user-data/ folder or user-data/sites or any of its subfolders
        # it will be evaluated as ruby inline as it loads.
        if File.exists?(File.join(vagrant_dir,'user-data', 'ouro-mappings')) then
            eval(IO.read(File.join(vagrant_dir, 'user-data', 'ouro-mappings')), binding)
        end
        Dir[File.join( vagrant_dir, 'user-data', 'sites', '**', 'ouro-mappings')].each do |file|
            eval(IO.read(file), binding)
        end
        eval(IO.read(File.join(vagrant_dir, 'default-sites', 'ouro-mappings')), binding)

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

        # Prevents stdin error for Ubuntu
        config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

        # Make sure puppet is on the box
        config.vm.provision "shell",
            inline: "apt-get update && apt-get install -qy software-properties-common puppet"

        # Run the system setup on the first vagrant up.
        config.vm.provision "puppet" do |puppet|
            puppet.manifests_path    = "provision"
            puppet.manifest_file     = "manifests"
            puppet.module_path       = "provision/modules"
            puppet.facter            = { "fqdn" => "ouroboros" }
            puppet.hiera_config_path = "provision/hiera.yaml"
        end

        # Run provisioning required every time we startup the box.
        config.vm.provision "puppet", run: "always" do |puppet|
            puppet.manifests_path    = "user-data/"
            puppet.manifest_file     = "vhosts"
            puppet.module_path       = "provision/modules"
            puppet.facter            = { "fqdn" => "ouroboros" }
            puppet.hiera_config_path = "provision/hiera.yaml"
        end

        # Vagrant Triggers
        #
        # If the vagrant-triggers plugin is installed, we can 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 provision/lib/bin for details.
        if defined? VagrantPlugins::Triggers

            config.trigger.before :up do
                system('./provision/lib/bin/vagrant_init.sh')
                if File.exists?(File.join(vagrant_dir,'user-data', 'ouro-init.sh')) then
                    system('./user-data/ouro-init.sh')
                end
                Dir[File.join( 'user-data/sites', '**', 'ouro-init.sh')].each do |file|
                    print file
                    system(file)
                end
            end

            config.trigger.before :halt do
                run_remote "bash /vagrant/provision/lib/bin/vagrant_halt.sh"
                if File.exists?(File.join(vagrant_dir,'user-data', 'ouro-halt.sh')) then
                    system('./user-data/ouro-halt.sh')
                end
                Dir[File.join( 'user-data/sites', '**', 'ouro-halt.sh')].each do |file|
                    print file
                    system(file)
                end
            end

            config.trigger.before :suspend do
                run_remote "bash /vagrant/provision/lib/bin/vagrant_suspend.sh"
                if File.exists?(File.join(vagrant_dir,'user-data', 'ouro-suspend.sh')) then
                    system('./user-data/ouro-suspend.sh')
                end
                Dir[File.join( 'user-data/sites', '**', 'ouro-suspend.sh')].each do |file|
                    print file
                    system(file)
                end
            end

            config.trigger.before :destroy do
                if File.exists?(File.join(vagrant_dir,'user-data', 'ouro-destroy.sh')) then
                    system('./user-data/ouro-destroy.sh')
                end
                Dir[File.join( 'user-data/sites', '**', 'ouro-destroy.sh')].each do |file|
                    print file
                    system(file)
                end
            end
        end

        puts "";
        puts "\033[38;5;196m=================================================================="
        puts "\033[38;5;33m   _____ _   _______ ___________  ___________ _____ _____  \033[38;5;118m__"
        puts "\033[38;5;33m  |  _  | | | | ___ \\  _  | ___ \\|  _  | ___ \\  _  /  ___|  \033[38;5;118m_|"
        puts "\033[38;5;33m  | | | | | | | |_/ / | | | |_/ /| | | | |_/ / | | \\ `--.  \033[38;5;118m__|"
        puts "\033[38;5;33m  | | | | | | |    /| | | | ___ \\| | | |    /| | | |`--. \\"
        puts "\033[38;5;33m  \\ \\_/ / |_| | |\\ \\\\ \\_/ / |_/ /\\ \\_/ / |\\ \\\\ \\_/ /\\__/ /"
        puts "\033[38;5;33m   \\___/ \\___/\\_| \\_|\\___/\\____/  \\___/\\_| \\_|\\___/\\____/"
        puts "\033[38;5;196m=================================================================="
        puts ""
        puts "  \033[38;5;80mOuroboros:   \033[38;5;118m3.3.1"
        puts ""
        puts "  \033[38;5;80mDocs:        \033[38;5;220mhttps://gitlab.ahc.ufl.edu/WebServices/ouroboros-lamp/wikis/home"
        puts ""
        puts ""
        puts "\033[0m"

        config.vm.post_up_message="\033[38;5;118mOuroboros is up and running. Happy Developing!"

    end
end

Please note, if you are using Homestead or a different Vagrantfile format, we
may be unable to assist with your issue. Try to reproduce the issue using a
vanilla Vagrantfile first.

Debug output

https://gist.github.com/ChrisWiegman/1a890b8d1851bf09ffe5afd81901621c

Expected behavior

Puppet provisioner should have run

Actual behavior

Vagrant produces the following error:
```
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

cp /tmp/vagrant-puppet/vagrant_facts.yaml /etc/puppetlabs/facter/facts.d/vagrant_facts.yaml

Stdout from the command:

Stderr from the command:

cp: cannot create regular file '/etc/puppetlabs/facter/facts.d/vagrant_facts.yaml': No such file or directory```

Steps to reproduce

  1. Upgrade Vagrant to 2.0.4
  2. Run Vagrant Up
bug provisionepuppet regression

Most helpful comment

@ChrisWiegman - Apologizes for the regression. I've put up a pull request for the fix. It should be good to go in the next release! For now you should be ok to use the prior release. Thanks!

All 6 comments

@ChrisWiegman - Apologizes for the regression. I've put up a pull request for the fix. It should be good to go in the next release! For now you should be ok to use the prior release. Thanks!

Thanks for the quick fix @briancain !

I have the same trouble. How fix it?

Setting structured_facts = nil in the provisioner configuration will fix the issue until the next release.

2.1.1 seem to have fixed this issue. Good work! So no workaround which @ChrisWiegman has proposed (for 2.0.x series only, I guess?)

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings