Updated Pygments


I’m using Pygments for quite some time now and I just noticed there was a new version available (1.5). I installed that and I was wondering if there would be a lexer included for Puppet. Well, it wasn’t, but a short Google action directed me to the Pygments lexer for the Puppet DSL.

Of course my old CentOS 5 system with Python 2.6 doesn’t want to install this, so I hacked the Puppet lexer into Pygments.

Here’s an example of the result:

class generic::ssh {
	$ssh_service       = hiera("ssh_service")
	$ssh_packages      = hiera("ssh_packages")
	$ssh_debug         = hiera("ssh_debug",         "undef")
	$permit_root_login: hiera("permit_root_login",	"no")
	$ssh_users         = hiera_array("ssh_users",	"undef")
	$ssh_groups        = hiera_array("ssh_groups",	"undef")

	package { $ssh_packages:
		ensure => present,
		before => File["/etc/ssh/sshd_config"],
	}

	file { "/etc/ssh/sshd_config":
		ensure  => present,
		content => template("generic/sshd_config.erb"),
		notify  => Service["${ssh_service}"],
	}

	service { $ssh_service:
		ensure     => running,
		enable     => true,
		hasrestart => true,
		hasstatus  => true,
	}
}

and an example of the Hiera Yaml file:

---

# SSH Settings
permit_root_login    : 'no'
ssh_service          :
                       - 'sshd'
ssh_users            :
                       - 'root'
                       - 'tonk'
ssh_groups           :
                       - 'wheel'
ssh_packages         :
                       - 'openssh'
                       - 'openssh-clients'
                       - 'openssh-server'

Nice ;-)

See also