Skip to content

Instantly share code, notes, and snippets.

@kensykora
Last active August 29, 2015 14:05
Show Gist options
  • Save kensykora/7e215c5ddfbef16b0b23 to your computer and use it in GitHub Desktop.
Save kensykora/7e215c5ddfbef16b0b23 to your computer and use it in GitHub Desktop.
Running Puppet in Packer

By @dylanmei

This works for me. Maybe there's something here for you as well.

in template.json, simplified

  ...
  "provisioners": [{
      "type": "file",
      "source": "./puppet",
      "destination": "C:/Windows/Temp/puppet"
    }, {
      "type": "file",
      "source": "./scripts/site.yaml",
      "destination": "C:/Windows/Temp/site.yaml"
    }, {
      "type": "file",
      "source": "./scripts/site.pp",
      "destination": "C:/Windows/Temp/site.pp"
    }, {
      "type": "shell",
      "remote_path": "/tmp/script.ps1",
      "execute_command": "{{.Vars}} cmd /c powershell C:/Windows/Temp/script.ps1",
      "scripts": [
        "./scripts/puppet.ps1",
        "./scripts/reboot.ps1"]
  }]
  ...

and in puppet.ps1

puppet apply --verbose --modulepath='C:/Windows/Temp/puppet/modules' --hiera_config='C:/Windows/Temp/site.yaml' --detailed-exitcodes C:/Windows/Temp/site.pp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment