How to print something when running Puppet client?

Here is the puppet script with all the available puppet log functions. log_levels.pp node default { notice(“try to run this script with -v and -d to see difference between log levels”) notice(“function documentation is available here: http://docs.puppetlabs.com/references/latest/function.html”) notice(“————————————————————————–“) debug(“this is debug. visible only with -d or –debug”) info(“this is info. visible only with -v or … Read more

Run `apt-get update` before installing other packages with Puppet

Since Puppet 2.6.0 a new feature “relationship syntax” was introduced. An example in Puppet 2.6.0 and above would look like this: exec { “apt-update”: command => “/usr/bin/apt-get update” } Exec[“apt-update”] -> Package <| |> Every time a package command is executed, the dependency (in our case ‘apt-update’) will be triggered fist. You can even define … Read more

How do you add items to .dockerignore?

The .dockerignore file is similar to the .gitignore syntax. Here are some example rules: # Ignore a file or directory in the context root named “modules” modules # Ignore any files or directories within the subdirectory named “modules” # in the context root modules/* # Ignore any files or directories in the context root beginning … Read more

puppet only exec when file does NOT exist

Have you tried this? onlyif => “test ! -f /usr/local/bin/papply” Not sure if Puppet can use the ‘!’ character Perhaps a better alternaltive: creates => ‘/usr/local/bin/papply’ even if i don’t like the fact that the command doesn’t really creates the file

Call Puppet function from Puppet template?

Inside templates you have access to a scope object. All of the functions that you can access in the puppet manifests can be accessed via that scope object, although not via the same name. Prepend “function_” to the beginning of the function name. For example, here I included one template inside another: <%= scope.function_template(“template2.erb”) %> … Read more

Use puppet to set hostname?

Take a look at my “renaming” definition for ideas. It assumes Debian, and might work on Ubuntu as well. define rename() { # We only need puppet so we can restart it. In practice, there’s # little point in renaming a machine through puppet without a # running puppet service include puppet::conf # We only … Read more