Configure CUPS with CFEngine 3

I use CFEngine3 to manage several Ubuntu computers. One task I wanted to do the other day was centrally manage printers. That way, when I setup a new computer, I don’t have to worry about setting up printers. Thankfully, cups uses simple plain text config files (unlike gsettings…). To set up the printers on a new machine, all you have to do is copy the /etc/cups/printers.conf file and all files in the /etc/cups/ppd/ directory to the new machine. This method could also be used to easily backup printer configuration or to transfer printers from an old computer to a new one.

Anyway, here is some cfengine code to do the job:

	"printerPPDsInstalled" expression => fileexists("/etc/cups/ppd/myPrinter.ppd");
		create => "true",
		copy_from => secure_cp("/my/network/location/printers/ppd",""),
		depth_search => recurse("inf"),
		perms => mog("755","root","lp");
		create => "true",
		perms => mog("755","root","lp"),
		classes => if_repaired('restart_cups'),
		copy_from => secure_cp("/my/network/location/printers/printers.conf","");
		"/usr/sbin/service cups restart";

This entry was posted in Linux, Networking, System Administration, Uncategorized and tagged , , , , , , , , . Bookmark the permalink.

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>