Installing printers with Puppet14. Feb '16

Introduction

This guide is for anyone interested in installing printers remotely using Puppet for Ubuntu 14.04.

Important

Avoid procuring Canon printers

So far I haven't seen a sane way to install Canon printers. A reasonable printer doesn't need local drivers/filters and uses platform independent protocol such as Internet Printing Protocol.

Dependencies

First install the CUPS module for Puppet on the Puppetmaster:

puppet module install mosen-cups

For the workstations add some packages to enable printing stack:

# Install CUPS and filters
package { "system-config-printer-gnome": ensure => installed }
package { "cups": ensure => installed }
package { "ghostscript": ensure => installed }
package { "unpaper": ensure => installed }
package { "printer-driver-all" => installed }

# PPD-s
package { "openprinting-ppds": ensure => installed }
package { "hpijs-ppds": ensure => installed }
package { "hp-ppd": ensure => installed }
package { "foomatic-db-compressed-ppds": ensure => installed }

Detecting printers

Following should discover printers sitting on the network as well as ones connected via USB:

lpinfo -v

If that's not helpful use nmap to discover the ports on the printer's IP-address:

nmap 192.168.?.?

Installing HP LaserJet 2100

This printer uses JetDirect protocol which means the document has to prepared locally on the computer and then sent via TCP 9100 port to the printer. Use the vendor name and model name bits to figure out which is the most suitable PPD for the printer:

lpinfo -m | grep HP | grep Laser | grep 2100 | grep recommended

Corresponding Puppet snippet:

printer { "HP-LaserJet-2100":
    ensure => present,
    uri => 'socket://192.168.2.12',
    description => 'HP LaserJet 2100',
    model => 'foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/HP-LaserJet_2100-pxlmono.ppd',
    page_size => 'A4'
}

In lpinfo -v you can identify such printers by socket:// protocol used in the URI.

Installing Lexmark 410dn

This printer uses Internet Printing Protocol over TCP port 631. In this case the document is sent over network in PostScript format and printer takes care of the rest. Printer definition file still has to supply some information about the supported page sizes, duplex support etc.

printer { "Lexmark-MS410dn":
    ensure      => present,
    uri         => 'ipp://10.254.201.50:631/ipp',
    description => 'Lexmark MS410dn',
    model       => 'foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/Lexmark-MS410dn-Postscript.ppd',
    page_size    => 'A4'
}

In lpinfo -v you can identify such printers by ipp:// protocol used in the URI.

Installing USB printers

Here are some examples how USB printers are installed. In most cases lpinfo -v was used to determine the device URI and lpinfo -m was grepped to identify suitable printer model:

HP LaserJet 1505:

printer { "HP-LaserJet-1505n":
    ensure      => present,
    uri         => "usb://HP/LaserJet%20P1505n?serial=KQ154T9",
    description => "HP LaserJet 1505n",
    model       => "foo2zjs:0/ppd/foo2zjs/HP-LaserJet_P1505n.ppd",
    page_size    => 'A4'
}

HP LaserJet 1200:

printer { "HP-LaserJet-1200":
    ensure      => present,
    uri         => 'usb://HP/LaserJet%201200?serial=00CNBP009193',
    description => 'HP LaserJet 1200',
    model       => 'lsb/usr/hplip/HP/hp-laserjet_1200n-hpijs.ppd',
    page_size    => 'A4'
}

HP DeskJet 2540:

printer { "HP-DeskJet-2540":
    ensure => present,
    uri => 'usb://HP/Deskjet%202540%20series?serial=CN4CO5F38C0604&interface=1',
    description => 'HP DeskJet 2540',
    model => 'lsb/usr/hplip/HP/hp-deskjet_2540_series-hpijs.ppd',
    page_size => 'A4'
}
Lexmark Ubuntu CUPS HP Puppet