Puppet Provisioner custom command

12 views
Skip to first unread message

vishanth bharadwaj

unread,
Dec 18, 2018, 4:31:44 PM12/18/18
to Packer
Hi,
The puppet masterless provisioner has the following command. In simpler terms this does like puppet apply --detailed-exitcodes  /tmp/puppet-masterless/init.pp.

Is there a way to do puppet apply --modulepath=/tmp/modules/puppet_manifest -e 'include classname' ? 
I saw the go provisioner file but looks like though it may be able to take in the modulepath and all other details but it maynot be able to omit the manifest file. Like the command can be modified but not completely changed, Is this true?

cd {{.WorkingDir}} &&
    {{if ne .FacterVars ""}}{{.FacterVars}} {{end}}
    {{if .Sudo}}sudo -E {{end}}
    {{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}}
  puppet apply --detailed-exitcodes
    {{if .Debug}}--debug {{end}}
    {{if ne .ModulePath ""}}--modulepath='{{.ModulePath}}' {{end}}
    {{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}}
    {{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}}
    {{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
    {{.ManifestFile}}

vishanth bharadwaj

unread,
Dec 19, 2018, 12:41:01 PM12/19/18
to Packer
So I found a solution for this.
Using a File resource upload your folders into /tmp/modules
In the json add extra arguments as this
      "extra_arguments" : ["--modulepath=/tmp/modules","--disable_warnings"," deprecations"," -e 'include <classname>'"] 

The actual command that comes up on packer will be --> puppet apply --detailed-exitcodes --modulepath=/tmp/modules --disable_warnings  deprecations  -e 'include <class_name>' /tmp/packer-puppet-masterless/manifests 
Unfortunately we cannot leave the manifest_file column blank so it may cause a double uploading of your manifest. But hey u can upload a dummy init.pp too...
The init.pp manifest will be something like this.
class <class_name>{
include <class_name>::<another_module_name>
}

ex
class abcd{
include abcd::xyz
Reply all
Reply to author
Forward
0 new messages