Giter Site home page Giter Site logo

puppet-cups's Introduction

puppet-cups module

Important

After git tag 1.4.0_RC1 I have made a non-backwards compatible change to the way ppd_options and options parameters work. If you want to use the old behavior, please use tag 1.4.0_RC1 or 1.3.0

User Guide

Overview

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

Limitations:

  • It currently does not support classes.

Installation

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

puppet module install mosen-cups

You can also clone the source repository into your module path, but be aware that HEAD is sometimes broken.

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", # OR
    model       => "drv:///sample.drv/okidata9.ppd", # Model from `lpinfo -m`
}
  • 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",

    # Printer driver/description
    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      => {  }, # Hash of options ( name => value ), supplied as -o flag to lpadmin.

    # Vendor/driver options
    page_size    => 'A4',
    input_tray   => 'Tray1',
    color_model  => 'CMYK',  # or 'Gray' usually for grayscale.
    duplex       => '',
    
    # AND Any other custom driver specific option...
    ppd_options  => { 'HPOption_Duplexer' => 'False' }, # Hash of vendor PPD options, set on creation.
}
  • To find valid vendor/ppd values for a printer, install it locally using the vendor supplied PPD and run lpoptions -p <dest> -l. You can also read the PPD if that's your thing.
  • Note that some options like shared and error_policy are parameters available at creation time only.

Default Printer

To make the basic printer from the previous section the default:

default_printer { "Basic_Printer":
    ensure => present,
    require => Printer['Basic_Printer'],
}

Note that this has almost zero effect on Mac OS X, due to the GUI not really respecting the system wide lpoptions.

Why not add a default property to the printer resource? Because the command line makes it unfeasible to set the default printer to nothing. This makes it impossible for all instances to have default => false. It also means that changing default from true to false sometimes fails and creates a non-idempotent resource. (This could be overcome in future by editing /etc/cups/lpoptions).

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 probably shouldn't use lpoptions because it only governs the default when submitting jobs under certain circumstances.

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

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

Acceptance Tests

You can execute the beaker tests starting with:

BEAKER_destroy=no bundle exec rspec spec/acceptance

And then re-use the provisioned guests with

BEAKER_destroy=no BEAKER_provision=no bundle exec rspec spec/acceptance

Unset BEAKER_destroy after testing has finished or VM is dirty for the purposes of testing.

You may also use BEAKER_set=centos6, for example, if you do not want to test against the default vagrant box (Currently Ubuntu Precise).

puppet-cups's People

Contributors

ckaenzig avatar clauded avatar deadpoint avatar hggh avatar ih84ds avatar lamawithonel avatar leinaddm avatar leoarnold avatar mattr- avatar mcanevet avatar mosen avatar ncsutmf avatar ody avatar richardc avatar tequeter avatar timmooney avatar tomas-edwardsson avatar xcompass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-cups's Issues

Language Setting for lpstat

We see a bug with this great module on MacOSX 10.11 systems that do not have English set as their main language. The reason is that the output of lpstat is localized. A stackexchange article directed us to unset the SOFTWARE environment variable and a first quick fix in provider/default_printer/cups.rb seems to work but is probably not the way this should be solved. I can PR the dirty "fix" if you want me to.

[1]
http://unix.stackexchange.com/questions/33833/lpstat-and-localization-under-mac-os-x

RHEL 5 support lacking?

Hello:

I have a block that looks like this:

  @printer { 'HPC-P-HPSBFQPF':
    uri         => 'lpd://hpc-p-hpsbfqpf',
    description => 'HP LaserJet 4015n',
    location    => 'WPC QPF Desk',
    model       => 'drv:///hp/hpcups.drv/hp-laserjet_p4015n.ppd',
    tag         => 'floor_4',
  }

When I try to apply it to a RHEL 5.10 system, I get this in Foreman:

Could not evaluate: Execution of '/usr/sbin/lpadmin -p HPC-P-HPSBFQPF -E -DHP LaserJet 4015n -mdrv:///hp/hpcups.drv/hp-laserjet_p4015n.ppd -vlpd://hpc-p-hpsbfqpf -LWPC QPF Desk -o printer-is-shared=false' returned 1: lpadmin: Unable to copy PPD file!

Looking into it, I tried running the lpadmin command on the system:

[root@host ~]# /usr/sbin/lpadmin -p HPC-P-HPSBFQPF -E -DHP LaserJet 4015n -mdrv:///hp/hpcups.drv/hp-laserjet_p4015n.ppd -vlpd://hpc-p-hpsbfqpf -LWPC QPF Desk -o printer-is-shared=false
lpadmin: Unknown argument 'LaserJet'!

Any ideas?

Default printer and other bugs

Hello, first of all I would like to say that you did very good job!

Testing enviroment:
Client: CentOS 6.5
Printers: PRINTER1 - printer is already present (HP CP3525)
PRINTER2 - printer added by puppet
Puppet master version: 3.6.2

We tested some features of your module and found this issues:

  1. Default printer
    If we use class in this way:
    default_printer { "PRINTER2":
    ensure => present,
    require => Printer['PRINTER2'],
    }

Geppetto (IDE for puppet dev) returns: Unknow resource type: 'default_printer'
Puppet on client returns this error message: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type default_printer
Also I tried to skip this settings for default printer but puppet set it as a default anyway.
Result from - system-config-printer: Default printer is PRINTER1
- lpstat -d: Default printer is PRINTER2 (from puppet module)
But it should be PRINTER1 because the defaultprinter options was not specified.
And of course programs like firefox takes settings from lpstat.

  1. I think there are some other bugs in puppet settings and system-config-printer. For example if new printer is created with these settings:

$pagesize = A4,
$optionduplex = true,
$outputmodel = Normal,
$colormodel = Gray,
printer { 'TESTPRINTER':
.
.
options => {'PageSize' => $pagesize,
'OptionDuplex' => $optionduplex,
'OutputModel' => $outputmodel,
'ColorModel' => $colormodel,
},
}

Variables are used because of RedHat Sattelite6.

Printer is added correctly but there are some wierd things.
ColorModel is set to Gray
result in system-config-printer => ColorModel is set to Color
result in lpoptinos -l => ColorModel/Output Mode: *Gray RGB

I've tested ColorModel with many other forms like Grayscale, Gray, Black and so on but without success. However, if I try to print something with this printer it will print in grayscale!! So settings are correct.

DuplexerInstalled is to TRUE
result in system-config-printer => DuplexerInstalled is unchecked
result in lpoptinos -l => OptionDuplex/Duplexer Installed: False *True

  1. If I try to add printer with lpadmin:
    lpadmin -p PRINTER2 -E -v lpd://IPADDRESS/LPRQUE -m 'drv:///hp/hpcups.drv/hp-color_laserjet_cp3525-pcl3.ppd' -o Media=A4 -o PageSize=A4 -o ColorModel=Gray -o OptionDuplex=True -o OutputMode=Normal

Everything works, also system-config-printer and lpoptions resulting in very same output.

Again thank you for your work!
Regards, J. Štefan

option changed at every puppet run?

I have a definition for a printer that looks like this:

printer { 'wolfprint-blackandwhite' :
ensure => present,
uri => 'ipps://print.ncsu.edu/printers/WolfPrint-BlackAndWhite',
model => 'drv:///sample.drv/generic.ppd',
options => {
'Option1' => 'True',
},
}

Every time puppet runs I get new output:

Notice: /Stage[main]/Itecsprinters::Pa_5/Printer[wolfprint-blackandwhite]/options: options changed {} to '{"Option1"=>"True"}'

Thus it appears this module is not idempotent? Should I be worried that it keeps changing options at every new puppet run? Thanks for any ideas you may have about this.

Error During Deployment

I am trying to deploy this module, it looks absolutely awesome, but I've hit a snag and I'm not sure what else I can do to troubleshoot.

Please see my current PP file here: https://goput.it/ykq.txt
And the output from my client here: https://goput.it/dyp.txt

Any suggestions you would have would be greatly appreciated.

Cheers
Kirk

Updating the printer driver

We recently replaced the copiers with new versions, and put them in under the same names. Unfortunately, it doesn't appear that puppet-cups is updating the driver. I haven't had a chance to dig into it to see if it doesn't check that if the printer already exists.

`accept` property not working

According to the messages, it would appear to be working correctly, but in actuality it does not seem to be doing as indicated:

$ lpstat -t
scheduler is running
system default destination: dell
device for dell: socket://10.1.193.23:9100
dell accepting requests since Tue 11 Sep 2012 03:26:39 PM EDT
printer dell is idle. enabled since Tue 11 Sep 2012 03:26:39 PM EDT
$ sudo -i puppet agent --test
info: Retrieving plugin
info: Loading facts in printers
info: Loading facts in printers
info: Caching catalog for myhost.mydomain.com
info: Applying configuration version '1347394849'
notice: Finished catalog run in 6.83 seconds
$ sudo cupsreject dell
$ lpstat -t
scheduler is running
system default destination: dell
device for dell: socket://10.1.193.23:9100
dell not accepting requests since Tue 11 Sep 2012 03:26:39 PM EDT -
Rejecting Jobs
printer dell is idle. enabled since Tue 11 Sep 2012 03:26:39 PM EDT
Rejecting Jobs
$ sudo -i puppet agent --test
info: Retrieving plugin
info: Loading facts in printers
info: Loading facts in printers
info: Caching catalog for myhost.mydomain.com
info: Applying configuration version '1347394849'
notice: /Stage[main]/Mydomain::Myhost/Printer[dell]/accept: accept changed 'false' to 'true'
notice: Finished catalog run in 9.70 seconds
$ lpstat -t
scheduler is running
system default destination: dell
device for dell: socket://10.1.193.23:9100
dell not accepting requests since Tue 11 Sep 2012 03:26:39 PM EDT -
Rejecting Jobs
printer dell is idle. enabled since Tue 11 Sep 2012 03:26:39 PM EDT
Rejecting Jobs
$ sudo cupsaccept dell
$ lpstat -t
scheduler is running
system default destination: dell
device for dell: socket://10.1.193.23:9100
dell accepting requests since Tue 11 Sep 2012 03:26:39 PM EDT
printer dell is idle. enabled since Tue 11 Sep 2012 03:26:39 PM EDT

Using username and password in uri re-applies printer resource

I need to add a username and password to the uri for a samba printer. Problem with that is that lpstat -v (naturally) won't return a uri with username and password in them, which is probably why the resource of my printer is always re-applied. Is there any way to solve that?

Thanks in advance!

Release point tag.

Hi,
Thank you for your work on this module. Would it be possible to tag the 1.3.0 release so it can be easily referenced?

git tag -a 'v1.3.0' -m 'v1.3.0' && git push --tags

Thanks.
Jonathan

Doesn't manage Service[cups]???

After ditching my old cups module in puppet for yours everything seemed to be running smooth. However, upon building a new host I was surprised to see this kind of error:

Error: /Stage[main]/Local::Subsys::Cups/Printer[brother-guten]: Could not evaluate: Execution of '/usr/sbin/lpadmin -x brother-guten' returned 1: lpadmin: Unable to connect to server: Bad file descriptor

I traced this to the fact that the cups service wasn't running. Shouldn't your module be managing that as well?

Supported Platforms?

Hi,

This module looks pretty cool. Thanks for putting it up here. What platforms did you have in mind when you wrote it? I'm trying to implement your example on OS X 10.7.

Manifest:

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
}

Results:

err: /Stage[main]//Printer[basic_printer]: Could not evaluate: undefined method `downcase' for #MatchData:0x104b0b3f0

OS X 10.5 compatibility?

It looks it does work under 10.5 because the cupsaccept command doesn't exist.

Is it possible to get it to work under 10.5? Hopefully I'll get some time in the next couple of days to dig into it and see.

module does nothing for me

I'd like to replace my own hack at CUPS management with this splendid looking module, but unfortunately nothing at all seems to happen. After attempting a printer like I wanted, I finally resorted to this ever so simple of one:

printer { "Basic_Printer":
    ensure        => present,
    uri              => "lpd://hostname/printer_a",
    description => "This is the printer description",
    model        => "raw",
}

My catalog applies w/o any errors, but I see no evidence of this resource when running 'puppet agent --test'. If I deliberately misspell 'uri' in the above, I get an error regarding an invalid parameter, so I can see it is at least being parsed. Is there some form of silent exit for unsupported platforms? Ruby is not my native tongue, but I see no obvious reason why this shouldn't work on Fedora 16.

Forge release

Hello,

Would it be possible to update the forge modules please?

Thank you!

Unexpected error messages

Using the Basic_Printer in your example documentation, I got the following errors during the first catalog application:

info: Retrieving plugin
info: Loading facts in /etc/puppet/modules/mosen-cups-1.0.0/lib/facter/printers.rb
Could not retrieve printers: No such file or directory - LANG=C /usr/bin/lpstat -p
info: Caching catalog for puppet.example.com
info: Applying configuration version '1346861178'
err: Could not prefetch printer provider 'cups': Execution of '/usr/bin/lpstat -v' returned 1: lpstat: No destinations added.

notice: /Stage[main]/Example::puppet/Printer[Basic_Printer]/ensure: created
notice: Finished catalog run in 6.93 seconds

If I rerun "puppet agent --test" again, things change slightly:

info: Retrieving plugin
info: Loading facts in /etc/puppet/modules/mosen-cups-1.0.0/lib/facter/printers.rb
Could not retrieve printers: No such file or directory - LANG=C /usr/bin/lpstat -p
info: Caching catalog for puppet.example.com
info: Applying configuration version '1346864465'
err: /Stage[main]/Example::puppet/Printer[Basic_Printer]: Could not evaluate: undefined method `captures' for "Basic_Printer":String
notice: Finished catalog run in 8.14 seconds

The print queue did get created on the first shot, but are these errors to be expected?

Printers are recreated on each run as long as the options variable are passed.

When doing a puppetrun, the module does Notice me about changes even if there is none. This happens only when the options hash is passed in.

Ok (options array is commented out):

printer { "Basic_Printer":
ensure => present,
name => "pullprintricoh_ps",
uri => "lpd://pullprint.domain/pullprintricoh_ps",
location => "Ricoh PS on campus",
description => "This is the printer description",
ppd => "/usr/share/ppd/pullprintricoh_ps.ppd",
shared => false,
enabled => true,
#options => { media => 'A4', duplex => 'DuplexNoTumble' },
}

Not Ok:

printer { "Basic_Printer":
ensure => present,
name => "pullprintricoh_ps",
uri => "lpd://pullprint.domain/pullprintricoh_ps",
location => "Ricoh PS on campus",
description => "This is the printer description",
ppd => "/usr/share/ppd/pullprintricoh_ps.ppd",
shared => false,
enabled => true,
options => { media => 'A4', duplex => 'DuplexNoTumble' },
}

Notice: /Stage[main]/App::Print::Precise/Printer[Basic_Printer]/options: options changed

Error: Could not prefetch printer provider 'cups': undefined method `include?' for nil:NilClass

Hei,

I updated code to newest master, and Now I get the following error:

Error: Could not prefetch printer provider 'cups': undefined method `include?' for nil:NilClass

It worked without this in an earlier version.

Working version: https://gist.github.com/kbotnen/8c52f7b99e759da152a8
Errorenous version: https://gist.github.com/kbotnen/2270d4a8857d657145e6

Despite the error the printers show up on lpstat -v.

If I try to remove a printer I get more errors

==> precise-gui: Error: Could not prefetch printer provider 'cups': undefined method `include?' for nil:NilClass
==> precise-gui: Notice: /Stage[main]/App::Print/Printer[IT_Print_Ricoh]/ensure: removed
==> precise-gui: Debug: Executing '/usr/sbin/lpadmin -x IT_Print_Ricoh'
==> precise-gui: Error: /Stage[main]/App::Print/Printer[IT_Print_Ricoh]: Could not evaluate: Execution of '/usr/sbin/lpadmin -x IT_Print_Ricoh' returned 1: lpadmin: The printer or class does not exist.

It looks like it try to remove the printer even if its not there (which it doesnt know since the prefetch step failed?).

All behaviour observed in a vagrant environment, with a Ubuntu 12.04 box.

  • Kristian -

does not hande of cups installation or services

This module does not handle the installation of the CUPS packages or enabling of the service, without which render this module broken. Extending it to include these is simple and will make it complete.

Error in PPD_Options handling?

Hi,

I noticed that the ppd_options do not seem to get set. You try to set them with lpoptions in cups.rb, but apparently they get ignored, at least on my Linux-box (OpenSuSE 12.3). I substituted lpoptions with lpadmin and they get set correctly.

cups.rb

315c319
<             lpoptions "-p", name, vendor_options

---
>             lpadmin "-p", name, vendor_options

$name property has unexpected value

I was hoping to create a printer using the following resource declaration:

printer { 'TESTJF':
    description     => 'test-automation target',
    location        => "virtual printer on ${fqdn}",
    model           => 'raw',
    shared          => true,
    uri             => "http://${fqdn}:631/printers/${name}",
} 

and expected it to be equivalent in all senses to:

printer { 'TESTJF':
    description     => 'test-automation target',
    location        => "virtual printer on ${fqdn}",
    model           => 'raw',
    shared          => true,
    uri             => "http://${fqdn}:631/printers/TESTJF",
}

However, the uri varies between these two examples, unexepectedly (to me, at
least). A puppet run of the first and then the second example yielded:

notice: /Stage[main]/Example::Myhost/Printer[TESTJF]/ensure: created

[...]

notice: /Stage[main]/Example::Myhost/Printer[TESTJF]/uri: uri changed 'http://myhost.mydomain.com:631/printers/example::myhost' to 'http://myhost.mydomain.com:631/printers/TESTJF'

Trys to install missing package

After adding mosen-cups 1.4.1 and defining a printer resource, puppet runs yield the following errors when attempting to install a missing package:

Info: Applying configuration version '1437589287'
Error: Mac OS X PKG DMG's must specify a package source.
Error: /Stage[main]/Cups::Install/Package[cups]/ensure: change from absent to present failed: Mac OS X PKG DMG's must specify a package source.
Notice: /Stage[main]/Cups::Service/Service[cups]: Dependency Package[cups] has failures: true
Warning: /Stage[main]/Cups::Service/Service[cups]: Skipping because of failed dependencies

Wrong usage of array.reject! in provider definition

Setup

I ran the latest commit on branch master of puppet-cups in this Vagrant box of Ubuntu Server 14.04 LTS 64bit with Cups 1.7.2 and

ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

My test manifest is:

# test-HP4730.pp
printer { "HP4730":
  ensure        => present,
  uri           => "socket://1.2.3.4:9100",
  description   => "A typical example of a network printer",
  location      => "Cubicle room",
  model         => "postscript-hp:0/ppd/hplip/HP/hp-color_laserjet_4730mfp-ps.ppd",
  ppd_options   => { "HPOption_MBM_Mixed" => "Standard" },
}
Error description

The first run of

puppet apply -dv test-HP4730.pp

everything was as expected. On the second run I got the message

Error: Could not prefetch printer provider 'cups': undefined method `has_key?' for nil:NilClass
Explanation

In the given test case - during self.prefetch(resources) of the cups provider - the arrays options and Option_Properties have no common key.

Problem: array.reject! will normally return the array of accepted keys but if there were no rejects, it returns nil, hence the error message.

Revelation

Suppose there was a common key. Then property_options is the array of accepted keys, i.e. will not contain any keys from Option_Properties. Immediately after that, we seek to set the "property options" of the resource if and only if property_options contains such keys - precisely those we just deleted from that array.

Suggested fix

I will provide a pull request.

hiera_hash lookup introduced in d0abd007 fails if not supplied hash

I've just upgraded my CUPS module to master to bring in Pull Request #52 to resolve #50 as I was having this problem.

Because of this I have also included commit d0abd00 which introduces hiera support for the variable
cups::printers.

If you don't set a hiera variable of cups::printers now an error is logged

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find data item cups::printers in any Hiera data file and no default supplied at /app/puppet/sapv2_cups/puppet/modules/cups/manifests/init.pp:21 on node toyecq01.tmca.com.au
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I have my own hiera variable that I use to store the cups printer definitions and I could swap this over to use cups::printers but this is probably not the behaviour you want especially if someone isn't using hiera.

Adding a blank default to the hiera_hash might resolve this issue but haven't tested it yet. I'll hopefully get some time to play around with a couple of options and submit a pull request in the next few days.

How do I set the printer-error-policy?

I'm trying to use this module to essentially replicate this command:

lpadmin -E -p TESTJF -v http://myhost:631/printers/TESTJF -o printer-error-policy=abort-job -m raw

My guess was to try something like:

printer { "TESTJF":
    # ...
    options => {
        printer-error-policy => 'abort-job',
    },
}

I don't get any errors when puppet runs, but inspection of printers.conf shows ErrorPolicy stop-printer whereas running the lpadmin command manually does lead to the expected abort-job setting. Where's the fault, in my approach or the module? I suspect the latter as I see no mention of the error-policy in puppet's debug output where lpadmin is shown.

auth-info-required

Hi,

When one sets the option "auth-info-required=none" on a printer using the module, the puppet run repeats this setting every run. This is because when one gets the options of printer (eg with lpoptions) the "auth-info-required" option is only shown if it is set to "negotiate" or "username, password". It is not shown at all if it is set to "none". The module should be modified so that it only sets "auth-info-required=none" if that setting is currently returned at all. if the option is not visible it should do nothing.

Best
Richard

err: Could not find a suitable provider for printer

Hi!

I'm just beginning to use your cups module (1.2.1) to manage a busy and complicated central print server for our campus. I'm sure you'll be seeing additional questions from me in the future -- apologies in advance. :-)

I have your module installed on our puppet master (2.7.14). pluginsync IS enabled. All our clients, including the print server (x86_64 RHEL 5.10, ruby 1.8.5), did receive a copy of printers.rb:

$ ls -al /var/lib/puppet/lib/facter/printers.rb -rw-r--r-- 1 root root 399 Jul 25 13:48 /var/lib/puppet/lib/facter/printers.rb

I can also see that the provider code for printer and printer_defaults ends up in /var/lib/puppet/lib/puppet/provider on the client.

However, when I add a test printer resource to the manifest for this node:

# # TVM: this will need to move elsewhere when testing is complete. # printer { 'iacc-228-b': ensure => present, enabled => true, shared => false, location => 'IACC 228 (Test)', uri => 'goprint-backend://hold-queue', model => 'HP LaserJet 4250 Postscript (recommended)', }

and then try apply that on the client, I get:

$ sudo puppet agent --test --noop [sudo] password for mooney: info: Retrieving plugin info: Loading facts in /var/lib/puppet/lib/facter/net_info.rb info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb info: Loading facts in /var/lib/puppet/lib/facter/ipmi_product.rb info: Loading facts in /var/lib/puppet/lib/facter/pacemaker.rb info: Loading facts in /var/lib/puppet/lib/facter/printers.rb info: Loading facts in /var/lib/puppet/lib/facter/biosversion.rb info: Loading facts in /var/lib/puppet/lib/facter/net_location.rb info: Caching catalog for gptest.ndsu.nodak.edu info: Applying configuration version '29193' err: Could not find a suitable provider for printer notice: Finished catalog run in 10.73 seconds

Notice that printers.rb does show up in the list of facts that are loaded.

In addition, when I run "facter -p", no printers show up in the list of facts, even though I've previously defined a couple printers using the web interface (so that I have a baseline to try and match using your printer resource).

It's clear that facter is using printers.rb, it's just not working for some reason:

$ sudo facter --debug -p printers value for printers is still nil

lpstat works:

$ /usr/bin/lpstat -p printer iacc-150-b is idle. enabled since Tue Nov 12 15:19:16 2013 printer test-b is idle. enabled since Tue Nov 12 18:06:59 2013 printer test-b-1 is idle. enabled since Wed Nov 13 12:27:03 2013

I feel like I must have something very basic wrong, but I'm not seeing what it is.

When I installed the module on our puppet master, I did:

$ sudo puppet module install --target-dir /etc/puppet/forge-modules mosen-cups $ ls -al /etc/puppet/forge-modules/ total 16 drwxr-xr-x 3 root root 4096 Jul 24 11:59 ./ drwxr-xr-x 9 root root 4096 Jul 25 15:39 ../ -rw-r--r-- 1 root root 793 Jul 24 11:57 README.TVM drwxr-xr-x 5 root root 4096 Jul 24 11:59 cups/ 03:48 PM config cups$sudo puppet module list /etc/puppet/modules ├── adauth (???) ├── adminutils (???)

pruning remaining output from our local modules
├── yum (???)
└── zabbix (???)
/usr/share/puppet/modules (no modules installed)
/etc/puppet/forge-modules
└── mosen-cups (v1.2.1)

One thought occurs to me -- is it possible that the provider/printer/cups.rb is being rejected because Red Hat doesn't ship /usr/sbin/cupsaccept and /usr/sbin/cupsreject ? It has all the other "commands" binaries in the places you are expecting them (some are symlinks to the actual command, because of the "alternatives" system), but cupsaccept and cupsreject are not present.

It's been a couple years since I've looked at the docs on providers so I can't recall for certain whether the commands place requirements on the system that might cause the provider to be rejected.

Hoping you have some thoughts on what the issue might be.

Invalid filetypes in module tar file

I am receiving a warning from r10k every time that this module is installed.

WARN -> These files existed in the module's tar file, but are invalid filetypes and were not unpacked: ["PaxHeader/mosen-cups-1.4.1", "mosen-cups-1.4.1/PaxHeader/checksums.json", "mosen-cups-1.4.1/PaxHeader/Gemfile", "mosen-cups-1.4.1/PaxHeader/Gemfile.lock", "mosen-cups-1.4.1/PaxHeader/lib", "mosen-cups-1.4.1/PaxHeader/manifests", "mosen-cups-1.4.1/PaxHeader/metadata.json", "mosen-cups-1.4.1/PaxHeader/Rakefile", "mosen-cups-1.4.1/PaxHeader/README.md", "mosen-cups-1.4.1/PaxHeader/spec", "mosen-cups-1.4.1/PaxHeader/tests", "mosen-cups-1.4.1/tests/PaxHeader/init.pp", "mosen-cups-1.4.1/spec/PaxHeader/acceptance", "mosen-cups-1.4.1/spec/PaxHeader/monkey_patches", "mosen-cups-1.4.1/spec/PaxHeader/puppet_spec", "mosen-cups-1.4.1/spec/PaxHeader/spec_helper.rb", "mosen-cups-1.4.1/spec/PaxHeader/spec_helper_acceptance.rb", "mosen-cups-1.4.1/spec/PaxHeader/unit", "mosen-cups-1.4.1/spec/unit/PaxHeader/provider", "mosen-cups-1.4.1/spec/unit/PaxHeader/type", "mosen-cups-1.4.1/spec/unit/type/PaxHeader/printer_defaults_spec.rb", "mosen-cups-1.4.1/spec/unit/type/PaxHeader/printer_spec.rb", "mosen-cups-1.4.1/spec/unit/provider/PaxHeader/cups_options_spec.rb", "mosen-cups-1.4.1/spec/unit/provider/PaxHeader/cups_spec.rb", "mosen-cups-1.4.1/spec/puppet_spec/PaxHeader/files.rb", "mosen-cups-1.4.1/spec/puppet_spec/PaxHeader/fixtures.rb", "mosen-cups-1.4.1/spec/puppet_spec/PaxHeader/matchers.rb", "mosen-cups-1.4.1/spec/puppet_spec/PaxHeader/verbose.rb", "mosen-cups-1.4.1/spec/monkey_patches/PaxHeader/alias_should_to_must.rb", "mosen-cups-1.4.1/spec/monkey_patches/PaxHeader/publicize_methods.rb", "mosen-cups-1.4.1/spec/acceptance/PaxHeader/cups_install_spec.rb", "mosen-cups-1.4.1/spec/acceptance/PaxHeader/default_printer_spec.rb", "mosen-cups-1.4.1/spec/acceptance/PaxHeader/nodesets", "mosen-cups-1.4.1/spec/acceptance/PaxHeader/printer_i18n_spec.rb", "mosen-cups-1.4.1/spec/acceptance/PaxHeader/printer_options_spec.rb", "mosen-cups-1.4.1/spec/acceptance/PaxHeader/printer_spec.rb", "mosen-cups-1.4.1/spec/acceptance/PaxHeader/printer_vendor_spec.rb", "mosen-cups-1.4.1/spec/acceptance/nodesets/PaxHeader/centos6.yml", "mosen-cups-1.4.1/spec/acceptance/nodesets/PaxHeader/default.yml", "mosen-cups-1.4.1/spec/acceptance/nodesets/PaxHeader/default_vbox.yml", "mosen-cups-1.4.1/spec/acceptance/nodesets/PaxHeader/precise.yml", "mosen-cups-1.4.1/manifests/PaxHeader/devel.pp", "mosen-cups-1.4.1/manifests/PaxHeader/init.pp", "mosen-cups-1.4.1/manifests/PaxHeader/install.pp", "mosen-cups-1.4.1/manifests/PaxHeader/params.pp", "mosen-cups-1.4.1/manifests/PaxHeader/service.pp", "mosen-cups-1.4.1/lib/PaxHeader/facter", "mosen-cups-1.4.1/lib/PaxHeader/puppet", "mosen-cups-1.4.1/lib/puppet/PaxHeader/provider", "mosen-cups-1.4.1/lib/puppet/PaxHeader/type", "mosen-cups-1.4.1/lib/puppet/type/PaxHeader/default_printer.rb", "mosen-cups-1.4.1/lib/puppet/type/PaxHeader/printer.rb", "mosen-cups-1.4.1/lib/puppet/type/PaxHeader/printer_defaults.rb", "mosen-cups-1.4.1/lib/puppet/provider/PaxHeader/default_printer", "mosen-cups-1.4.1/lib/puppet/provider/PaxHeader/printer", "mosen-cups-1.4.1/lib/puppet/provider/PaxHeader/printer_defaults", "mosen-cups-1.4.1/lib/puppet/provider/printer_defaults/PaxHeader/cups_options.rb", "mosen-cups-1.4.1/lib/puppet/provider/printer/PaxHeader/cups.rb", "mosen-cups-1.4.1/lib/puppet/provider/default_printer/PaxHeader/cups.rb", "mosen-cups-1.4.1/lib/facter/PaxHeader/printers.rb"]

This message goes away after the initial environment creation.

printer pauses

when printing the printer pauses. unable to resume printing.

in my environment once a printer is added it should authenticate w/username and password current logged in user; instead it just hangs.

class macmodule::printers {

    #creates printers on mac
    printer { "CALPS01-ARTCLR03":

            ensure      => present,

            description => "CALPS01_ARTCLR03",

            enabled     => true,

            shared      => false,

            location    => "CART",

            ppd         => "/Library/Printers/PPDs/Contents/Resources/Ricoh Aficio SP C811DN.gz",

            uri         => "lpd://calps01/CALPS01_ARTCLR03",

                }

}

now printing printer not recognized

Hi,
you should amend line 192 in cups.rb with a "now printing" string, otherwise the printer detection fails. Nothing critical, but generates a recreation of printers.

Regards

Lars

               printer = { :accept => :true } # Current printer entry being parsed
             end

-            header = line.match(/printer (.*) (disabled|is idle|now printing)/).captures # TODO: i18n
+            header = line.match(/printer (.*) (disabled|is idle)/).captures # TODO: i18n

             printer[:name] = header[0]
             printer[:enabled] = (header[1] != 'disabled') ? :true : :false

Will there be any further releases to Forge?

Hello! We've been depending on specific commit references from GitHub. The latest release to Forge was 1.4.1 in April 2015. Will there be any more releases to Forge or, at the very least, tagged releases on GitHub?

default queue support

In your README.md you state this module has the limitation that it "currently does not set default printers." Then later in the OSX-specifics section you mention "If you want to set the default printer, you cannot use lpoptions or lpadmin to do it." While I don't have an OSX and won't contest anything you've said there, I do see that the lp(1) man page has:

CUPS provides many ways to set the default destination. The "LPDEST" and "PRINTER"
environment variables are consulted first. If neither are set, the current default set using the
lpoptions(1) command is used, followed by the default set using the lpadmin(8) command.

Likewise, lpoptions(1) states:

-d destination[/instance]
Sets the user default printer to destination. If instance is supplied then that particular
instance is used. This option overrides the system default printer for the current user.

Indeed the "loptions -d foo" approach works for me in Fedora. It seems to me that this should be relatively easy to implement. Or am I missing something here?

puppet applying printers on every run, sharing

I've set up puppet to apply printer settings here at the office.
There are a few things that I haven't been able to figure out yet.

The resulting printers all have "sharing" set to "on", no matter what "sharing =>" is set to.

The other thing is the machines I'm testing on here reinstall the printers on every run, i.e. every 30mins. The same setup at home only reinstalls the printers if I delete them manually.

What am I doing wrong?

Cheers
Phil

Here's an example printer:

printer { "ineo":
ensure => present,
uri => "dnssd://ineo203._ipp._tcp.local.",
description => "Ineo+ 203",
ppd => "/Library/Printers/PPDs/Contents/Resources/GENERIC36C-6.gz",
shared => false,
location => "OG",
ppd_options => { 'SelectColor' => 'Grayscale','ColorModel' => 'Gray' },
}

Confine to machines with CUPS?

I added my first Windows machine to Puppet today, and it bombed when trying to load in the custom facts from puppet-cups.

I added a confine :operatingsystem => :Darwin to it to stop the error, but didn't know if that was the best way of doing it.

support for non-english systems [patch]

I'm using puppet on french systems (locale defaults to FR_fr)

# LANG=C puppetd -t
info: Retrieving plugin
info: Loading facts in printers
info: Loading facts in printers
Could not retrieve printers: undefined method `captures' for nil:NilClass
Could not retrieve printers: undefined method `captures' for nil:NilClass
Could not retrieve printers: undefined method `captures' for nil:NilClass
...

Indeed, lpstat -p gives :

# lpstat -p
l’imprimante Cups-PDF est inactive, mais activée depuis jeu. 05 juil. 2012 14:58:22 CEST
l’imprimante imp-b14 est inactive, mais activée depuis mer. 11 juil. 2012 15:38:31 CEST
l’imprimante imp-inf6 est inactive, mais activée depuis ven. 06 juil. 2012 18:27:12 CEST
l’imprimante imp-inf7 est inactive, mais activée depuis mer. 11 juil. 2012 14:11:57 CEST
    fichier de données envoyé correctement

with this patch to /lib/facter/printers.rb

6c6
<     stdin, stdout, stderr = Open3.popen3('/usr/bin/lpstat -p')

---
>     stdin, stdout, stderr = Open3.popen3('LANG=C /usr/bin/lpstat -p')

everything's great!

Unmatched single quote

I'm getting errors such as:

err: Could not prefetch printer provider 'cups': Unmatched single quote: ' printer-state=3 printer-state-change-time=1347391485 printer-state-reasons=none printer-type=8433692 printer-uri-supported=ipp://localhost:631/printers/dell

when location contains an apostrophe such as:

location => "John's office"

This is NOT a critical issue for me, but thought you might like to know about it.

doubts in options

Good morning, I'm in trouble.
I added the following options:
options => {
'PageSize' => A4,
'Duplex' => DuplexNoTumble,
'ColorModel' => Gray,
},

the result is not expected.

Notice: / Stage [main] / Main / Node [l020073] / Cups :: Printers test [printer3] / Printer [COR1787] / options: options {} changed to 'DuplexDuplexNoTumbleColorModelGrayPageSizeA4'

can you help me?

sorry to be pendantic, but ...

This module is quickly shaping up to a real gem for dealing with CUPS, which is one of those services that just doesn't want to be tamed by puppet so easily -- witness its bizarre habit of rewriting config files immediately after a puppet File type is applied. With this module, it's now ridiculously easy. Congrats and many thanks for making it!

However, there's one minor detail I think (IMHO) would improve this module even further and that's the choice of naming. We're really not creating a printer here, but instead printer_queue. For example, I'm going to be using this module to create queues that are daisy-chained across a WAN such that a user submits a print job to queue X where CUPS forwards the job for X to another queue named Y on a distant host and the process may be repeated again to Z. It just seems weird to think of X and Y (and to some extent, even Z) as printers.

I see that the CUPS documentation liberally uses the two terms interchangeably, which is understandable. Perhaps the best solution would be to support an alias of some sort so that our puppet manifests could have something like:

printer_queue { 'X':
...
}

printer_queue { 'Y':
...
}

printer { 'Z':
...
}

Fail to add printer on first puppetrun precise

Hi,

Tried the new code (master today) and got problems on the first run.

It seems that it add the printers, but then removes them again :/. If I run puppet once more the will come in as normal.

Have tried on precise so far, will try on trusty tomorrow.

==> precise: Debug: Prefetching cups resources for printer
==> precise: Debug: Puppet::Type::Printer::ProviderCups: Fetching all queue device URIs
==> precise: Debug: Executing '/usr/bin/lpstat -v'
==> precise: Debug: Puppet::Type::Printer::ProviderCups: Failed to fetch URIs, see --debug command output above
==> precise: Debug: Executing '/usr/bin/lpstat -l -p'
==> precise: Debug: Puppet::Type::Printer::ProviderCups: execution of lpstat failed, returning empty hash
==> precise: Notice: /Stage[main]/App::Print/Printer[pullprintricoh_ps]/ensure: created
==> precise: Debug: Executing '/usr/sbin/lpadmin -p pullprintricoh_ps -E -P/usr/share/ppd/uib/pullprintricoh_ps.ppd -LRicoh PS on UiB 
campus -DPullPrintRicoh on pullprint.uib.no -vlpd://pullprint.uib.no/pullprintricoh -o printer-is-shared=false'
==> precise: Debug: Executing '/usr/sbin/lpadmin -p pullprintricoh_ps -o PageSize=A4 -o ColorModel=CMYK -o Duplex=DuplexNoTumble'
==> precise: Debug: Printer[pullprintricoh_ps](provider=cups): Failed to add printer successfully, deleting destination. error: undefi
ned method `cupsenable' for #
==> precise: Debug: Executing '/usr/sbin/lpadmin -x pullprintricoh_ps'
==> precise: Error: /Stage[main]/App::Print/Printer[pullprintricoh_ps]: Could not evaluate: undefined method `cupsenable' for #
==> precise: Notice: /Stage[main]/App::Print/Printer[pullprintricoh_ps2]/ensure: created
==> precise: Debug: Executing '/usr/sbin/lpadmin -p pullprintricoh_ps2 -E -P/usr/share/ppd/uib/pullprintricoh_ps.ppd -LRicoh PS on UiB
 campus -DPullPrintRicoh on pullprint2.uib.no -vlpd://pullprint2.uib.no/pullprintricoh -o printer-is-shared=false'
==> precise: Debug: Executing '/usr/sbin/lpadmin -p pullprintricoh_ps2 -o PageSize=A4 -o ColorModel=CMYK -o Duplex=DuplexNoTumble'
==> precise: Debug: Printer[pullprintricoh_ps2](provider=cups): Failed to add printer successfully, deleting destination. error: undef
ined method `cupsenable' for #
==> precise: Debug: Executing '/usr/sbin/lpadmin -x pullprintricoh_ps2'
==> precise: Error: /Stage[main]/App::Print/Printer[pullprintricoh_ps2]: Could not evaluate: undefined method `cupsenable' for #

newbie question

When I try syncing I get "Invalid resource type printer".

I added to /etc/puppet/manifests/node.pp inside my node definition:

   printer { "Basic_Printer":
        ensure        => present,
        uri              => "lpd://hostname/printer_a",
        description => "This is the printer description",
        ppd            => "/Library/Printers/PPDs/Printer.ppd", # OR
        model        => "Valid model name from lpinfo -m",
    }

What am I missing? both server and computer are ubuntu 12.04

Error 400 on SERVER: Invalid parameter duplex

Hi, I've been trying to set this up as per the readme, and this error crops up
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter duplex on Printer[UTprint]...
if I include the line
duplex = 'DuplexNoTumble'
So, I figured I would try to get around it, and since the command
lpadmin -p utprint -o Duplex=DuplexNoTumblehave the line
works, and the options => { } parameter is suppoedly handed off to lpadmin -o, I tried this
options => { 'Duplex'=>'DuplexNoTumble', }
With no luck.
Is this an issue with the readme, or something else?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.