Giter Club home page Giter Club logo

Comments (14)

leoarnold avatar leoarnold commented on September 24, 2024 1

Have you tried this? https://github.com/leoarnold/puppet-cups#systemd-based-linux-distributions

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

Regenerating types on the puppet master seems to make the Pis happy, but the Ubuntu systems are still giving the same error. ETA: nope, the Pis are happy the first run after removing the queue by hand and then make the error message forever after.

Uncommenting the PPD line about the filter and installing the filter Perl script makes no difference. I tend not to use the filter because it's for managing user boxes that we don't make use of because we have PCounter.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

Thanks for the suggestion. It fails pdk test unit though. Where does the variable $::systemd in the workaround class come from?

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

Ah, I see, it's a custom fact. Unit tests now happy.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

Manifest now saying:

class profiles::printing {

  # for convenience so I don't type the same thing over and over
  $ppdpath    = '/usr/share/cups/model'
  $filterpath = '/usr/lib/cups/filter'
  $filter     = 'KMbeuEmpPS.pl'
  $models     = ['KMC759ux.ppd']
  case $facts['lsbdistid'] {
    'Raspbian': {
      $packages = ['cups-bsd', 'a2ps']
    }
    default: {
      $packages = ['cups-bsd', 'a2ps', 'indicator-printers']
    }
  }


  include ksmb

  class { 'cups':
    default_queue => 'USB_Building_Printing',
    papersize     => 'A4',
  }

  include cups::workarounds::systemd_service_restart

  package { $packages:
    ensure => installed,
  }

  file { $ppdpath: ensure => directory }

  file { $filter:
    ensure  => file,
    replace => yes,
    mode    => '0755',
    path    => "${filterpath}/${filter}",
    source  => "puppet:///modules/profiles/ppds/${filter}"
  }

  $models.each | $model | {
    file { $model:
      ensure  => file,
      replace => yes,
      source  => "puppet:///modules/profiles/ppds/${model}",
      path    => "${ppdpath}/${model}",
      group   => 'lp',
      mode    => '0644',
    }
  }

  cups_queue { 'USB_Building_Printing':
    ensure      => 'printer',
    uri         => 'ksmb://cs-print/USB-BUILDING-PRINTING',
    ppd         => "${ppdpath}/KOC759UX.ppd",
    shared      => false,
    enabled     => true,
    accepting   => true,
    description => 'All Urban Sciences printers, swipe your campus card at any printer to collect your job.',
    options     => {
      'KMDuplex'      => '2Sided',
      'PageSize'      => 'A4',
      'InputSlot'     => 'Tray4',
      'PaperSources'  => 'PC215',
      'Finisher'      => 'FS533',
      'KOPunch'       => 'PK519-4',
      'SaddleUnit'    => 'None',
      'PrinterHDD'    => 'HDD',
      'SelectColor'   => 'Grayscale',
      'Model'         => 'C458',
      'TextPureBlack' => 'On',
    },
  }

}

Acceptance test results:

  • The Pis are happy.
  • But the Ubuntu 18.04s are still saying:
Debug: Prefetching cups resources for cups_queue
Error: Could not prefetch cups_queue provider 'cups': IPP query 'ipptool -c ipp://localhost/ /dev/stdin' failed.
EXITCODE: 1
STDIN:
          {
            OPERATION CUPS-Get-Classes
            GROUP operation
            ATTR charset attributes-charset utf-8
            ATTR language attributes-natural-language en
            DISPLAY printer-name
            DISPLAY member-names
          }

STDOUT:

STDERR:
ipptool: Unable to connect to localhost on port 631 - Operation now in progress

Debug: Storing state
Debug: Pruned old state cache entries in 0.00 seconds
Debug: Stored state in 0.04 seconds
Error: Failed to apply catalog: IPP query 'ipptool -c ipp://localhost/ /dev/stdin' failed.
EXITCODE: 1
STDIN:
          {
            OPERATION CUPS-Get-Classes
            GROUP operation
            ATTR charset attributes-charset utf-8
            ATTR language attributes-natural-language en
            DISPLAY printer-name
            DISPLAY member-names
          }

STDOUT:

STDERR:
ipptool: Unable to connect to localhost on port 631 - Operation now in progress

The Error: Could not prefetch cups_queue provider 'cups' grabs my eye.

from puppet-cups.

leoarnold avatar leoarnold commented on September 24, 2024

At prefetch, Puppet takes a look around to find which print queues are installed

def self.prefetch(specified)
discovered = instances
specified.each_key do |name|
provider = discovered.find { |instance| instance.name == name }
specified[name].provider = provider if provider
end
end

It does so by running a few executions of the ipptool command line utility

ShellOut.new("ipptool #{switch} ipp://localhost#{resource} /dev/stdin", request)

The problem is Unable to connect to localhost on port 631 - Operation now in progress, i.e. the CUPS service is currently not listening on port 631, probably because it is restarting in order to implement the changed configuration file.

The workaround drops in a config which tells systemd that the CUPS service is not ready until it is listening to that specific port

systemd::dropin_file { 'wait_until_cups_listens_on_port_631.conf':
unit => $unit,
content => template(
'cups/_header.erb',
'cups/systemd/wait_until_cups_listens_on_port_631.conf.erb'
)
}

Obviously, systemd is failing us here.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

I am firing up git's magic time machine because this talk of systemd is ringing a bell.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

Summary: running cupsd with -f doesn't help.

Some years ago, a previous author of Puppet code at our site added a "monkey patch" to systemd:
/etc/systemd/system/cups.service

[Unit]
Description=CUPS Printing Service
Documentation=man:cupsd(8) man:cupsd.conf(5)
Requires=cups.socket
[Service]
ExecStart=/usr/sbin/cupsd -f
[Install]
Also=cups.socket cups.path
WantedBy=printer.target

I can't figure why this is needed and note that the cupsd manual says to use -l in the systemd unit, so I removed the monkey patch. When this problem started, I suspected the monkey patch to be a fix for it. Reinstating it doesn't resolve this problem though.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

My earlier manifests that don't use roles and profiles but used cups::resources in hiera were not affected. I'm going to try using cups::resources in Hiera within roles and profiles, somehow, but that will be tomorrow.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

I'm not sure why, but forcibly removing the monkey patch with file { '/etc/systemd/system/cups.service': ensure => absent } allows me to use cups_queue in my manifest, whereas not forcibly removing an already-present monkey patch (e.g. as a result of moving nodes from production to test without reinstalling the OS) forces me to use cups::resources hashes in Hiera. Even though cups::resources are turned into cups_queues.

Not complaining, my manifests now work.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

Sorry for taking up your time with something that turned out to be my problem.

from puppet-cups.

leoarnold avatar leoarnold commented on September 24, 2024

Here's some food for thought, in case you want to dig deep: A plain

file { '/etc/systemd/system/cups.service':
# ....
}

is bound for trouble. You need something to trigger a systemctl daemon-reload to make systemd aware of the (changed) service file. Then again, I'm unsure about how Ubuntu 18.04 LTS runs CUPS. Maybe there's even a conflict of interest with an old /etc/init.d/cups script.

Furthermore the monkey-patch should be integrated into the Puppet dependency tree, c.f.
https://github.com/leoarnold/puppet-cups#automatic-dependencies
and

contain cups::packages
contain cups::server
contain cups::queues
Class[cups::packages]
-> Class[cups::server]
-> Class[cups::queues]

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

You need something to trigger a systemctl daemon-reload to make systemd aware of the (changed) service file.

file { '/etc/.../cups.service': params => list } ~> class { 'cups': params => list } was in the old manifests to do exactly that, and is in the current manifest with ensure => absent to make the cups class reapply after removing the file, which causes at least one service reload based on the reports Foreman shows me.

Then again, I'm unsure about how Ubuntu 18.04 LTS runs CUPS. Maybe there's even a conflict of interest with an old /etc/init.d/cups script.

I will take a look on Monday (I use 18.04 at work) and report back. It's the least I can do.

from puppet-cups.

threepistons avatar threepistons commented on September 24, 2024

There is still cups and cups-browsed in /etc/init.d. The stock service files don't reference them. I removed the symlinks from /etc/rc5.d and rebooted and I still have CUPS running.

I suspect that the init.d files are packaged in CUPS for Systemd refuseniks and aren't relied on at all on Systemd systems.

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.