1

I am trying to create a Vagrant box using Packer, and everything works fine until I try to install Puppet in the Packer box. The Packer logs clearly says that Puppet is getting installed correctly. However, when I load up the box in Vagrant and SSH into it, Puppet is nowhere to be found (tested this with yum list | grep puppet). When I issue the commands that Packer's supposed to execute when creating the box directly on the Vagrant box and run my test command again, Puppet is in fact getting listed there.

I have already tried to rearrange the order of the scripts in the shell provision, but none of this helped at all. The commands to Puppet do seem to be working (seeing that I could get it working directly in the Vagrant box).

I have created a gist with all of my files. I am installing it on CentOS 7.1.

1 Answers1

0

First things I'd say:

  • make sure to cleanup at the really end (run cleanup.sh after puppet.sh)
  • yum list <package> will list all available packages (and installed packages), to know which packages are installed you should run yum list installed (you might have an issue in your repos or mirrors if you do not get any output at all from your command)
  • as you installed from rpm, you can also run rpm -qa | grep puppet to find out if the package has been installed, you should get something like (depending the version)

    [vagrant@vagrant ~]$ rpm -qa | grep puppet
    puppetlabs-release-6-11.noarch
    

From a quick view, the script looks good - I do install from the following script

install_puppet()
{
    echo "==> Installing Puppet"
    REDHAT_MAJOR_VERSION=$(egrep -Eo 'release ([0-9][0-9.]*)' /etc/redhat-release | cut -f2 -d' ' | cut -f1 -d.)

    echo "==> Installing Puppet Labs repositories"
    rpm -ipv "http://yum.puppetlabs.com/puppetlabs-release-el-${REDHAT_MAJOR_VERSION}.noarch.rpm"

    if [[ ${CM_VERSION:-} == 'latest' ]]; then
        echo "==> Installing latest Puppet version"
        yum -y install puppet
    else
        echo "==> Installing Puppet version ${CM_VERSION}"
        yum -y install "puppet-${CM_VERSION}"
    fi
}

so it does basically the same -

Update

Its very strange, I created a box from your gist and the box was okay - puppet was installed.

I only changed from puppet.sh

#!/bin/sh
#rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm 
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm 
yum -y install puppet

so I was able to install puppet 3.x rather than puppet 4.x - and I used an existing Vagrantfile with simple provisioning and all was ok

When I vagrant up the VM, provisioning for puppet was running and packaged installed.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • Thanks. I've switched the cleanup and puppet script (which I did just for testing) around and used your script for installing Puppet. It is still not being saved even though the logs of Packer indicating that it was correctly installed. I even ran the `rpm -qa | grep puppet` command in the Puppet script, where I got a correct output (`puppetlabs-release-7-11.noarch`), but this I get no output when I run it with Vagrant. –  Jan 12 '16 at 20:28
  • hum I would say puppet is correctly installed in your box - what the error when you vagrant up with a puppet provisioning ? – Frederic Henri Jan 12 '16 at 20:36
  • This is what I get when I run `vagrant up`: ==> default: Running provisioner: puppet... The `puppet` binary appears not to be in the PATH of the guest. This could be because the PATH is not properly setup or perhaps Puppet is not installed on this guest. Puppet provisioning can not continue without Puppet properly installed. –  Jan 12 '16 at 20:45
  • weird I made the box from your gist and it looks like its installed, just made a change to install puppet 3.x so I could test with existing provisioning I had – Frederic Henri Jan 13 '16 at 14:59
  • I've deleted the `.vagrant` and `.vagrant.d` folders from my system, and now it works! Thanks! –  Jan 13 '16 at 17:46
  • Good but you can also vagrant box add/remove and vagrant destroy VM if you need to keep directory – Frederic Henri Jan 13 '16 at 17:52