Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to add printer on first puppetrun precise #50

Open
kbotnen opened this issue Apr 16, 2015 · 3 comments
Open

Fail to add printer on first puppetrun precise #50

kbotnen opened this issue Apr 16, 2015 · 3 comments

Comments

@kbotnen
Copy link

kbotnen commented Apr 16, 2015

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 #

@kbotnen
Copy link
Author

kbotnen commented Apr 17, 2015

same problem on trusty.

What I discovered is that if I set "enabled: false" it will fail but now on

Failed to add printer successfully, deleting destination. error: undefi
ned method `cupsdisable' for #

Will continue to test.

@kbotnen
Copy link
Author

kbotnen commented Apr 17, 2015

Found the problem.

Will provide some code later today.

@kbotnen
Copy link
Author

kbotnen commented Apr 17, 2015

The problem seems to be defining of commands. For unknown reason the code that assign cupsenable/cupsdisable/cupsaccept/cupsreject is run after the methods is created.

If I remove the:

[ "/usr/sbin/cupsenable",
    "/usr/bin/cupsenable",
    "/usr/sbin/enable",
    "/usr/bin/enable"].each do |cups_command|
    if File.exists?(cups_command)
      commands :cupsenable => cups_command
      break
    end
  end
  [ "/usr/sbin/cupsdisable",
    "/usr/bin/cupsdisable",
    "/usr/sbin/disable",
    "/usr/bin/disable"].each do |cups_command|
    if File.exists?(cups_command)
      commands :cupsdisable => cups_command
      break
    end
  end
  #
  # Candidate locations for the accept and reject commands
  # Older Fedora and RHEL/CentOS 6.x and earlier have /usr/sbin/{accept,reject}
  # Solaris 11 & Illumos/OpenIndiana have the same.
  #
  [ "/usr/sbin/cupsaccept",
    "/usr/bin/cupsaccept",
    "/usr/sbin/accept",
    "/usr/bin/accept"].each do |cups_command|
    if File.exists?(cups_command)
      commands :cupsaccept => cups_command
      break
    end
  end
  [ "/usr/sbin/cupsreject",
    "/usr/bin/cupsreject",
    "/usr/sbin/reject",
    "/usr/bin/reject"].each do |cups_command|
    if File.exists?(cups_command)
      commands :cupsreject => cups_command
      break
    end
  end

and replace it with

  commands :cupsenable => 'cupsenable'
  commands :cupsdisable => 'cupsdisable'
  commands :cupsaccept => 'cupsaccept'
  commands :cupsreject => 'cupsreject'

It will work.

This require that the needed binaries are available in the path on the client, otherwise it will fail, as described here: https://docs.puppetlabs.com/guides/provider_development.html#suitability

The only problem with this approach is on the system where the binaries have other names like accept, reject, enable and disable.

I need to find a way to accomodate for those OSes.

I run puppet 3.4.2 on client and server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant