Giter Club home page Giter Club logo

Comments (15)

leoarnold avatar leoarnold commented on June 17, 2024

Interesting issue. The investigation might take a little more back and forth than usual, but will surely be beneficial for both sides, as puppet-cups aims to manage cupsd.conf from version 2.0 onwards. Please note that Puppet 3.x has reached end of life, so future versions of the module will drop support.

My first assumption towards the problem would be that the module's mechanism for queue discovery fails. So I would kindly ask you to ...

  1. Check whether the binary /usr/bin/ipptool is present. If not, upgrading to the latest version of puppet-cups from the Puppet Forge might already solve your issue.
  2. Ensure that the managed queues are actually present using lpstat -t.
  3. Paste the output of the command ipptool -c ipp://localhost/ request.ipp using
# request.ipp
{
  OPERATION CUPS-Get-Printers
  GROUP operation
  ATTR charset attributes-charset utf-8
  ATTR language attributes-natural-language en
  STATUS successful-ok
  DISPLAY printer-name
}

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

Here are the results if the ipptool command against the request.ipp script:

root@print:/home/me# ipptool -c ipp://localhost/ request.ipp
printer-name

lpstat -t:

scheduler is running
no system default destination
device for HP-LaserJet-M506-81: socket://172.16.0.81:9100
device for HP-LaserJet-M506DN-243: socket://172.16.0.243:9100
device for HP-LJP-P2055DN-202: socket://172.16.0.202:9100
HP-LaserJet-M506-81 accepting requests since Fri 27 Jan 2017 03:06:36 PM CST
HP-LaserJet-M506DN-243 accepting requests since Fri 27 Jan 2017 03:06:37 PM CST
HP-LJP-P2055DN-202 accepting requests since Fri 27 Jan 2017 03:06:36 PM CST
printer HP-LaserJet-M506-81 is idle.  enabled since Fri 27 Jan 2017 03:06:36 PM CST
printer HP-LaserJet-M506DN-243 is idle.  enabled since Fri 27 Jan 2017 03:06:37 PM CST
printer HP-LJP-P2055DN-202 is idle.  enabled since Fri 27 Jan 2017 03:06:36 PM CST

Also the version of ipptool:

# whereis ipptool
ipptool: /usr/bin/ipptool /usr/share/man/man1/ipptool.1.gz
# ipptool --version
CUPS v2.1.3

In regards to Puppet v3; Are you saying that this module won't be compatible with v4 or I need to make changes to my files to make them work with Puppet 4?

The tagged version of puppet-cups we use in our Puppetfile is 1.2.2.

Update:
I commented out in my code any changes to /etc/cups/cupsd.conf and cups.cocket. I reverted to a previous snapshot in my test system to rerun puppet agent -t. When testing with the ipptool command you suggested I get this:

# ipptool -c ipp://localhost/ request.ipp
printer-name
HP-LaserJet-M506-81
HP-LaserJet-M506DN-243
HP-LJP-P2055DN-202

from puppet-cups.

leoarnold avatar leoarnold commented on June 17, 2024

I set up a test environment with the CUPS configuration you provided and was not able to verify your issue. ipptool listed all installed queues as expected.

Let me list our evidence in your environment:

  • The queues are definitely installed and available locally on the node as per lpstat -t.
  • CUPS is definitely running and listening on port 631, otherwise the ipptool request would fail.
  • CUPS will not expose the available queues to the ipptool request.

My next assumption would be that there is a typo in your cupsd.conf, since Port 631 means Listen *:631, which is in conflict with Listen localhost:631.

My guess would be, that Nginx is listening on (say) port 8080 and then internally proxypassing the requests on to CUPS at localhost:631 which should not be exposed. If so, I suggest you delete Port 631 and just use Listen localhost:631 in your cupsd.conf.

from puppet-cups.

leoarnold avatar leoarnold commented on June 17, 2024

As for compatibility: At the top, you stated that you are using Puppet 3.8.5 (which EOLed in Dec 2016).

  • leoarnold-cups v1.x.x supports Puppet 3.x.x and 4.x.x.
  • leoarnold-cups v2.x.x will not work on Puppet 3.x.x anymore because it uses Puppet 4 syntax.

If leoarnold-cups v1.x.x works for you, it will keep working if you transition to Puppet 4.

When leoarnold-cups v2.0 ships and you want to benefit from the new options discussed in #7, you will have to run Puppet 4 and of course adapt your code, because you will want to get rid of your workaround for cupsd.conf and use the new cups::server class then.

Also, I am thinking about integrating your systemd-fix in leoarnold-cups v2.0, as it seems necessary to maintain idempotence.

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

@leoarnold,

Thank you. I appreciate you working with me on some of the issues that may not be related to the puppet-cups module.

I am working on testing what you have suggested. I am testing one change at a time. It looks like /lib/systemd/system/cups.socket may need localhost:631 also, as you mentioned 631 implies *:631. When only using 631, puppet would recreate the printers on each run. When using localhost:631 (as you recommended for the cupsd.conf file) Puppet would not recreate those printers.

I also noticed that a reboot was needed in between some of these changes. Simply restarting cups was not sufficient (or stop cups, make change, start cups) for Puppet to stop recreating printers. I suspect I am missing something here but I can get by rebooting.

Background: We are transitioning to Puppet 4 shortly. I look forward to working on it. Thank you for the helpful information.

from puppet-cups.

leoarnold avatar leoarnold commented on June 17, 2024

@lordbink Once tried and tested, please document your findings here. It could drastically reduce my need for experimentation and thereby accelerate the development of the module.

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

@leoarnold,

For reference, here is the cups systemd bug report and some possible solutions. My approach may or may not have been appropriate. It worked for our needs and there doesn't seem to be any problems with it. If you think of any let me know.

https://bugs.launchpad.net/ubuntu/+source/cups/+bug/1598300

As for the localhost:631 setting in cupsd.conf, you are absolutely correct. Once I removed port 631 and simply left "Listen localhost:631", puppet stopped recreating those printers. I will be doing more testing as this project progresses and definitely let you know what I find.

I am struggling with my nginx configuration, but I am assuming that is a completely separate issue unrelated to leoarnold-cups. I think it is related to my lack of understanding the best way to configure the cupsd.conf file with nginx.

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

Update:
ListenStream localhost:631 does not do anything in the way of keeping the web interface running. It also keeps other things from working like the web interface.

The following are my results from testing. I had to create a table to keep my own sanity in check. Every change I made was followed by a reboot to verify that those settings took. systemctl daemon-reload and /etc/init.d/cups restart did not seem to make a difference when applying changes. I was also connecting directly to http://host:631 directly, to eliminate potential issues from my nginx configuration.

cupsd.conf cups.socket web remote access ipptool tests show printers Cups keeps running
Listen 631 ListenStream=631 Yes No yes
Listen localhost:631 ListenStream=localhost:631 no yes no
Listen localhost:631 ListenStream=631 Yes No Yes
Listen 631 ListenStream=localhost:631 Yes No No
Listen localhost:631 <blank - no setting> No Yes No
Listen 631 <blank - no setting> Yes No No

I am pretty sure that I am not configuring cups correctly. Is there a setting other than Listen localhost:631 in cupsd.conf that will work with the ipptool command? Or is there a way to allow Listen 631 to work?

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

There may be a difference with cups 2.1.3-4 and 2.2.02-2 in how Listen is handled in cupsd.conf or how ipptools works. Through aggressive pinning on my LTS Xenial install I was able to get cups updated using the Yakkety repos. Port 631 alone was able to work with ipptools as well as the web interface.

I will investigate this further as it creates other problems for me. At least I know there are some differences between the two cups versions and I can work with that in mind. I would be tempted to simply upgrade to Yakkety if it was LTS, although using pinned packages may invalidate that approach.

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

I went back to stock Xenial for my cups packages. If I enable sharing for the printer, ipptool seems to work and thus puppet does not need to re-add the printer.

## Add printers to system. Adapted for Hiera.

define cups_print::resource::add_printer(
  ## Variable names should be the same from cups.conf
  $ensure       = $::cups_print::ensure,
  $model        = $::cups_print::driver,
  $connection   = $::cups_print::connection,
  $accepting    = true, ## Default setting
  $shared       = true, ## Default setting ## should be true for ipp to work
  $enabled      = true, ## Default setting
  )
  {

  validate_re($ensure, '^(printer|class|absent)$',
    "${ensure} is not supported for ensure. Allowed values are 'printer', 'class', and 'absent'.")

    case $ensure {
      'printer', default: {
        cups_queue { $name:
          ensure    => $ensure,
          model     => $model,
          uri       => $connection,
          accepting => $accepting,
          shared    => $shared,
          enabled   => $enabled,
        }
      }
#      'class':{} ##WIP
#      'absent':{} ##WIP
    }
  }

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

Here is an update to my add_printer.pp resource:

## Add printers to system. Adapted for Hiera.

define mbx_cups_print::resource::add_printer(
  ## Variable names should be the same from printers.conf
  $ensure       = $::cups_print::ensure,
  $model        = $::cups_print::driver,
  $connection   = $::cups_print::connection,
  $location     = $::cups_print::location,
  $description  = $::cups_print::description,
  $accepting    = true,
  $shared       = true,  ## This needs to be true for ipptools to work
  $enabled      = true,
)
  {

  validate_re($ensure, '^(printer|absent)$',
    "${ensure} is not supported for ensure. Allowed values are 'printer' and 'absent'.")

  case $ensure {
    'printer', 'absent', default: {
      if $model != 'raw' {  ## raw printers do not have options and will error
        cups_queue { $name:
          ensure      => $ensure,
          location    => $location,
          description => $description,
          model       => $model,
          uri         => $connection,
          accepting   => $accepting,
          shared      => $shared,
          enabled     => $enabled,
          require     => Package['hplip'], ## make sure all drivers are available
          options     => {'PageSize' => 'Letter',}, ## offsite printing: move to hiera if we need A4
        }
      }
      else {
        cups_queue { $name:
          ensure      => $ensure,
          location    => $location,
          description => $description,
          model       => $model,
          uri         => $connection,
          accepting   => $accepting,
          shared      => $shared,
          enabled     => $enabled,
          require     => Package['hplip'], ## make sure all drivers are available
        }
      }
    }
#      'class':{} ## This will need to be looked at and tested
  }
}

We had some issues setting default paper size. I am uncertain if 'options' should be allowed to be blank/udefined. Some variation of the following simply did not work:

  if $model != 'raw' {  ## raw printers do not have options
    $options = "{'PageSize' => 'Letter',}"
  }
  else {
    $options = "''"
  }

...
        cups_queue { $name:
...
          options     => $options,
...
        }
...

Error:

Error: Failed to apply catalog: Parameter options failed on Cups_queue[HP-LaserJet-M506DN-243]: Please provide a hash value. at /etc/puppet/environments/signal_print_updates/modules/cups_print/manifests/resource/add_printer.pp:40

This is not an issue for us, but a continuation of what I have done previously by sharing my experiences. I hope this is beneficial. There may be a better approach to this that I have not thought of.

from puppet-cups.

lordbink avatar lordbink commented on June 17, 2024

No priority. Simply updating existing scripts. At some point when I get on the master branch (or 2.0) for my environment I will consider simply creating a branch to eventually be pushed/merged with the main project.

## define: mbx_cups_print::resource::add_printer
## Add printers to system. Adapted for Hiera.

define mbx_cups_print::resource::add_printer(
  ## Variable names should be the same from printers.conf
  $ensure       = $::cups_print::ensure,
  $model        = $::cups_print::driver,
  $connection   = $::cups_print::connection,
  $location     = $::cups_print::location,
  $description  = $::cups_print::description,
  $pagesize     = $::cups_print::pagesize,
  $duplex       = $::cups_print::duplex,
  $accepting    = true,
  $shared       = true,  ## This needs to be true for ipptools to work
  $enabled      = true,
)
  {

  validate_re($ensure, '^(printer|absent)$',
    "${ensure} is not supported for ensure. Allowed values are 'printer' and 'absent'.")

  ## This could be better. TODO: It is hard to gauge what to do with only one
  ## printer to use the duplex option.
  ## TODO: Option1 works when the settings are already correct (it does not rerun the job)
  ## It does not work when it tried to change this setting
  if $duplex != undef {
    $set_options = {
      'Duplex'   => $duplex, ##Duplex/2-Sided Printing: None *DuplexNoTumble DuplexTumble
      'Option1'  => 'True', ## Option1/Duplexer: False *True
      'PageSize' => $pagesize, ## offsite printing: allow a4
    }
  }
  else {
      $set_options = { 'PageSize' => $pagesize,} ## offsite printing: allow a4
  }


  case $ensure {
    'printer', 'absent', default: {
      if $model != 'raw' {  ## raw printers do not have options and will error
        cups_queue { $name:
          ensure      => $ensure,
          location    => $location,
          description => $description,
          model       => $model,
          uri         => $connection,
          accepting   => $accepting,
          shared      => $shared,
          enabled     => $enabled,
          require     => Package['hplip'], ## make sure all drivers are available
          options     => $set_options,
        }
      }
      else {
        cups_queue { $name:
          ensure      => $ensure,
          location    => $location,
          description => $description,
          model       => $model,
          uri         => $connection,
          accepting   => $accepting,
          shared      => $shared,
          enabled     => $enabled,
          require     => Package['hplip'], ## make sure all drivers are available
        }
      }
    }
#      'class':{} ## This will need to be looked at and tested
  }
}

from puppet-cups.

leoarnold avatar leoarnold commented on June 17, 2024

@lordbink Not sure if I caught up with all your questions:

  • The options key will not handle strings, should be fine with empty hashes, i.e. {}.
  • As far as I understand you removed the systemd workaround from your setup.
  • As of 0da4c5d, Class[cups] can manage the Listen and Webinterface directives in cupsd.conf. All others will be set to package vendor defaults.

Anything else? Or can we close the issue?

from puppet-cups.

leoarnold avatar leoarnold commented on June 17, 2024

Closing due to inactivity. Reopen if necessary.

from puppet-cups.

leoarnold avatar leoarnold commented on June 17, 2024

@tequeter I opted for a standalone class now. May those include it who run into problems:

https://github.com/leoarnold/puppet-cups#systemd-based-linux-distributions

from puppet-cups.

Related Issues (20)

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.