background preloader

Patterns

Facebook Twitter

[Puppet Users] How to handle apt-get -f install -y with Puppet.

Redundant patterns?

Patterns are still useful .. although some are redundant. Module Iptables Patterns - Puppet. The iptables module illustrated will help administer iptables rules. There are essentially three parts: the module-manifest which declares an iptables class and a defined-type for adding fragments, the rebuild-iptables script that rebuilds the iptables rules when a fragment is added or removed, and an area for fragments.

You will also need to create a modules/iptables/files/empty directory to force the purge attribute to work as expected, ie deleting no longer used fragments. modules/iptables/manifests/init.pp modules/iptables/files/rebuild-iptables #! /usr/bin/perl -w our $ID = q$Id: rebuild-iptables 344 2006-10-04 02:48:30Z digant $; # # rebuild-iptables -- Construct an iptables rules file from fragments. # # Written by Russ Allbery modules/iptables/files/fragments/ftp (sample) # FTP setup, requiring passive mode. Thanks for the recipe, I have taken what you have done here and modified it to be more versatile.

Main changes include: Here is a simpler alternative so far tested on Debian. Show Node Objects Patterns - Puppet. Note: The script does not work for puppet v2.7.6 This script accepts a host name and produces a list of objects in manifest syntax associated with that host. It is meant to be run on the puppetmaster host. By default only the ‘hostname’ fact is supplied but other facts can be specified by using the ‘—fact` option (multiple times if needed). If the argument to ’—fact' does not contain a ‘=’ sign it is interpreted as a file containing facts in YAML format as output by ‘facter —yaml’. User And Homedir Recipe Patterns - Puppet.

This might help someone. If you’re using a version higher than 0.22.1, this is probably fixed already, so you can simply check the reference to see how you should add a homedir directly from the user {} declaration. Otherwise, you can use this component: You can use it like this: This might help someone else. If you’re using a higher version, this could be fixed already, you can check the reference to see how you should add a homedir directly and hash from the user {} declaration.

Otherwise, you can use this component: Notes: I found that different systems put binarys in other locations, I used path to sort this out. Usefulness: This is obviously an extension to the pw provider used by FreeBSD, I’m sure the concept can be extended to other providers that are missing features. Other code: This code I’ve used to insert passwords when there is no OS support for managing hashes. Patterns - Puppet. Advanced Puppet Pattern - Puppet. When we left off in the Simplest Puppet Install Pattern, we had two files, our site manifest and a class configuring the sudo tool. The site manifest, /etc/puppet/manifests/site.pp, contained: # /etc/puppet/manifests/site.pp node default { include sudo } In this case the default node only contains a single class: sudo. The sudo class contained: This simple class performs only one function: managing the /etc/sudoers file. This is a good start but Puppet is capable of a whole lot more so let’s expand on this initial example.

Before we get too far along though, you’ll notice we’ve got a couple of configuration, .pp, files. We’ve already got the core of our new sudo module from the Simplest Puppet Install Pattern so let’s expand on the functions it performs for us. First, we’ve added a new resource type, package, and told it to install the sudo package and always ensure the package installed is the latest version. # mkdir /etc/puppet/modules/sudo/files Then we copy in our new sudoers file: Patterns - Puppet. Advanced Puppet Pattern - Puppet. When we left off in the Simplest Puppet Install Pattern, we had two files, our site manifest and a class configuring the sudo tool. The site manifest, /etc/puppet/manifests/site.pp, contained: # /etc/puppet/manifests/site.pp node default { include sudo } In this case the default node only contains a single class: sudo. The sudo class contained: This simple class performs only one function: managing the /etc/sudoers file.

This is a good start but Puppet is capable of a whole lot more so let’s expand on this initial example. Before we get too far along though, you’ll notice we’ve got a couple of configuration, .pp, files. We’ve already got the core of our new sudo module from the Simplest Puppet Install Pattern so let’s expand on the functions it performs for us. First, we’ve added a new resource type, package, and told it to install the sudo package and always ensure the package installed is the latest version. # mkdir /etc/puppet/modules/sudo/files Then we copy in our new sudoers file: