4

I'm very new to the this whole Packer/Vagrant,Puppet world. I'm trying to build my first VM using Packer and Puppet.

I can successfully build a virtualbox and I've included a shell script provisioner to install puppet. I've ssh'ed into the VM to verify that it works and puppet is installed.

Then I added an additional puppet-masterless provisioner that looks simply like this:

# java dependency
package { 'openjdk-7-jdk' :
    ensure => present
}

When I run packer, it gets to this point and gets stuck:

==> virtualbox-iso: Provisioning with Puppet...
virtualbox-iso: Creating Puppet staging directory...
virtualbox-iso: Uploading manifests...
virtualbox-iso: Running Puppet:   sudo -E puppet apply --verbose --modulepath='' --detailed-exitcodes /tmp/packer-puppet-masterless/manifests/ubuntu.pp

Any suggestions would be helpful. Even on how to debug it to see what's going on behind the scenes

kane
  • 5,465
  • 6
  • 44
  • 72
  • One thing that you can try is to enable the `--debug` flag on Puppet. I'm not familiar with Packer, but it seems like you have to use the `execute_command` optional parameter of the [`puppet` provisioner](http://www.packer.io/docs/provisioners/puppet-masterless.html). – cassianoleal Mar 15 '14 at 00:59
  • Another suggestion would be to comment out the `package` resource so that Puppet will execute using an empty manifest. If it works, you can uncomment the resource back and try to run `puppet apply` from inside the VM -- I would copy and paste the command from Packer's output. That might give you some clues. – cassianoleal Mar 15 '14 at 01:00
  • Good ideas. I'll give it a try. I'd like to use puppet in the spirit it was meant to be used, so I'll try debugging it. – kane Mar 15 '14 at 05:21
  • The -E option on sudo may be tripping you up also if sudo isn't configured to allow overriding of the env_reset option. – rojs Mar 24 '14 at 01:48
  • #kane, Were you able to find a solution? I'm seeing the same problem. It stalls even with an empty manifest file. Running the `puppet apply`... command from within the VM works fine and returns exit code 0. – Saimon May 09 '14 at 19:04
  • No, I haven't been able to resolve it. I've reverted to using just vagrant on its own – kane May 12 '14 at 19:10

1 Answers1

3

I was having the same problem, and changed the execute_command to receive the password of the vagrant user.

"override": {
    "virtualbox-iso": {
    "execute_command": "echo 'vagrant' | {{.FacterVars}}{{if .Sudo}} sudo -S -E {{end}}puppet apply  --verbose --modulepath='{{.ModulePath}}' {{if ne .HieraConfigPath \"\"}}--hiera_config='{{.HieraConfigPath}}' {{end}} {{if ne .ManifestDir \"\"}}--manifestdir='{{.ManifestDir}}' {{end}} --detailed-exitcodes {{.ManifestFile}}"
     }
 }

The whole block looks like this

{
        "type": "puppet-masterless",
        "manifest_file": "../puppet/manifests/base.pp",
        "module_paths": [
            "../puppet/modules/"
        ],
        "override": {
            "virtualbox-iso": {
                "execute_command": "echo 'vagrant' | {{.FacterVars}}{{if .Sudo}} sudo -S -E {{end}}puppet apply  --verbose --modulepath='{{.ModulePath}}' {{if ne .HieraConfigPath \"\"}}--hiera_config='{{.HieraConfigPath}}' {{end}} {{if ne .ManifestDir \"\"}}--manifestdir='{{.ManifestDir}}' {{end}} --detailed-exitcodes {{.ManifestFile}}"
            }
        }
    }

Source: Found an example here https://github.com/AdoptOpenJDK/openjdk-virtual-images/blob/master/packer/openjdk-development/openjdk-development.json

alhvi
  • 33
  • 6