Shebang Puppet – #!/usr/bin/env pup – Script to run short standalone Puppet scripts

Write and run single file Puppet scripts.

Install Wrapper Script

To run Puppet scripts, you need a wrapper script ‘pup’ by Alex Wilson. This wrapper script needs to be saved only once per machine.

#!/bin/bash
# Save this to /usr/local/bin/pup
exec puppet apply "$@"

After that, you can create standalone Puppet scripts with shebang.

Write a Shebang Puppet Script

Save this script to a file

#!/usr/bin/env pup
# hello.pp

file { "/tmp/helloPup.txt":
        ensure => "present",
}

Enjoy

Now you can run your standalone hello.pp script

$ chmod ugo+rx hello.pp
$ ./hello.pp
Notice: Compiled catalog for tero.example.com in environment production in 0.05 seconds
Notice: /Stage[main]/Main/File[/tmp/helloPup.txt]/ensure: created
Notice: Finished catalog run in 0.05 seconds
$

There is more

Puppet can do so much more. See Puppet Reading List on how to really use Puppet.

Want to run anything in a shebang script? C++? Have a look at Tero’s C++ Scripting CPPT from 2007.

See also

Wilson, Alex 2015: Enforcing State with Puppetlets (in Probably Fine blog)

Karvinen, Tero 2007: Tero’s C++ Scripting – cppt

#!/usr/bin/env pup
# Copyright 2016 Tero Karvinen http://TeroKarvinen.com

file { “/tmp/helloPup.txt”:
ensure => “present”,
}

Posted in Uncategorized | Tagged , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Picks

  • Boxing Clock for AndroidOcton8 Diving T-ShirtsShaking Tower Panda Android GameLearn Chinese with Android
  • Student projects