Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

puppet module for the CUPS printing system

branch: master

Immutable options printed in the output of lpoptions have been filter…

…ed out, so that they will not appear in executions of puppet resource printer.

puppet resource (ralsh) works again, and correctly moves properties like shared and page size to their respective properties.
tidy up some code into a shorter form.
support for setting PageSize, InputSlot, ColorMode and Duplex via properties (page_size, input_tray, color_mode, duplex). The values cannot be validated though.
latest commit 53f66122be
mosen authored April 15, 2014
Octocat-spinner-32 lib Immutable options printed in the output of lpoptions have been filter… April 15, 2014
Octocat-spinner-32 spec Merge pull request #16 from mattr-/fix-coverage October 01, 2013
Octocat-spinner-32 tests Testing error_policy parameter. April 14, 2014
Octocat-spinner-32 .gitignore ignore the coverage directory January 24, 2013
Octocat-spinner-32 Modulefile testing cups options as lpadmin parameter instead of lpoptions. April 14, 2014
Octocat-spinner-32 README.md Testing error_policy parameter. April 14, 2014
Octocat-spinner-32 Rakefile Add coverage when running under Ruby 1.9.x January 24, 2013
README.md

puppet-cups module

User Guide

Overview

This type provides the ability to manage cups printers and options.

Limitations:

  • It currently does not support classes.
  • It currently does not set default printers.
  • It does not set vendor ppd options (where an external process is responsible for modifying the ppd).

Installation

You can install the latest release version from the module forge by executing this command:

puppet module install mosen-cups

If you are feeling brave, or want to test the version in development you can clone the github repository into your module path.

This module provides new types in the form of plugins, so pluginsync must be enabled for every agent in the puppet configuration (usually /etc/puppet/puppet.conf) like this:

[agent]
pluginsync = true

Without pluginsync enabled, any manifest with a printer resource in it will throw an error or possibly just do nothing.

Examples

Basic

The most basic printer install possible:

printer { "Basic_Printer":
    ensure      => present,
    uri         => "lpd://hostname/printer_a",
    description => "This is the printer description",
    ppd         => "/Library/Printers/PPDs/Printer.ppd", # PPD file will be autorequired
}
  • The uri identifies how you will connect to the printer. running lpinfo -v at the command line will give you some valid uri prefixes.
  • The description only appears in certain dialogs on linux and friends. On OSX the description is the actual name of the printer.
  • The ppd or model parameter specifies the "driver" to use with this printer. You should use model wherever available because most driver software will install straight into the cups model directory. You can get a list of valid models by running lpinfo -m at the command line.

Removing the printer "Basic_Printer" from the previous example:

printer { "Basic_Printer":
    ensure      => absent,
}

Advanced

An example using almost every possible parameter:

printer { "Extended_Printer":
    ensure       => present,
    uri          => "lpd://localhost/printer_a",
    description  => "This is the printer description",
    location     => "Main office",
    ppd          => "/Library/Printers/PPDs/Printer.ppd", # Full path to vendor PPD
    # OR
    model        => "", # A valid model, you can list these with lpinfo -m, this is usually what you would call a
                        # list of installed drivers.
    # OR
    interface    => "/path/to/system/v/interface/file", # Interface script run for this destination
    shared       => false, # Printer will be shared and published by CUPS
    error_policy => abort_job, # underscored version of error policy
    enabled      => true, # Enabled by default
    options      => { media => 'A4' }, # Hash of options ( name => value ), these are non vendor specific options.
    ppd_options  => { 'HPOption_Duplexer' => 'False' }, # Hash of vendor PPD options
}
  • The easiest way to find out a list of valid options for any single printer is to install that printer locally, and run lpoptions -l at the command line.
  • Note that some options like shared and error_policy are parameters available at creation time only. This is currently because lpadmin does not supply information about the current value of those options, so puppet won't know what to do in that instance.

Facts

The module provides access to one additional facter fact "printers", which provides a comma separated list of installed printers.

For more information about printer options, models, and uri's, refer to the CUPS documentation.

Bugs

Please submit any issues through Github issues as I don't have a dedicated project page for this module.

Developer Guide

OSX Specifics

Printer Presets

Each printer can have a set of options, normally presented in the print dialog, saved as a named preset. Named presets are stored in property lists at the following location:

~/Library/Preferences/com.apple.print.custompresets._PRINTER_QUEUE_NAME_.plist

Default Printer

If you select "Last Used Printer", it will select the printer in:

~/Library/Preferences/org.cups.PrintingPrefs.plist

As the default printer.

If you want to set the default printer, you cannot use lpoptions or lpadmin to do it. The system preference pane primarily reads and writes to:

~/.cups/lpoptions

To determine the current default printer queue. You can make this file part of your login script or manage it using a commercial osx management solution.

Default Paper Size

Again, OSX doesn't respect lpoptions when you set default page size via lpoptions or lpadmin. The file containing the actual default page size is:

~/Library/Preferences/com.apple.print.PrintingPrefs.plist

Under the plist key DefaultPaperID, which has a string that relates to a non-localised paper size. The PrintCore framework seems to have these listed in a binary plist under OSX 10.8. You can dump some localised strings using

/usr/libexec/plistbuddy -c "print" /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/Current/Resources/English.lproj/Localizable.strings

Vendor PPD Options

The provider does not currently generate PPD files based upon the vendor supplied printer definition. This means that if the vendor has supplied a PPD with Apple extensions i.e You see a UI which allows you to pick printer features, then you need to generate your own ppd first for distribution.

I would recommend doing a manual installation of the printer with the customizations from the ui picker, and then using the resulting PPD as the printer description. On OS X you can retrieve the ppd from /private/etc/cups/ppd after you have customized the printer features.

Contributing

You can issue a pull request and send me a message if you like, and I will consider taking the patch upstream :)

Testing

The tests need a lot of improvement, but you can run them with RSpec in the typical way:

Make sure you have:

rake

Install the necessary gems:

gem install rspec

And run the tests from the root of the source code:

rake test
Something went wrong with that request. Please try again.