{"action":"opened","issue":{"url":"https://api.github.com/repos/leoarnold/puppet-cups/issues/12","repository_url":"https://api.github.com/repos/leoarnold/puppet-cups","labels_url":"https://api.github.com/repos/leoarnold/puppet-cups/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/leoarnold/puppet-cups/issues/12/comments","events_url":"https://api.github.com/repos/leoarnold/puppet-cups/issues/12/events","html_url":"https://github.com/leoarnold/puppet-cups/issues/12","id":203743467,"number":12,"title":"Issue recreating existing printers","user":{"login":"lordbink","id":5795393,"avatar_url":"https://avatars.githubusercontent.com/u/5795393?v=3","gravatar_id":"","url":"https://api.github.com/users/lordbink","html_url":"https://github.com/lordbink","followers_url":"https://api.github.com/users/lordbink/followers","following_url":"https://api.github.com/users/lordbink/following{/other_user}","gists_url":"https://api.github.com/users/lordbink/gists{/gist_id}","starred_url":"https://api.github.com/users/lordbink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lordbink/subscriptions","organizations_url":"https://api.github.com/users/lordbink/orgs","repos_url":"https://api.github.com/users/lordbink/repos","events_url":"https://api.github.com/users/lordbink/events{/privacy}","received_events_url":"https://api.github.com/users/lordbink/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-27T21:22:37Z","updated_at":"2017-01-27T21:22:37Z","closed_at":null,"body":"**Given**\r\n- Ubuntu 16.04\r\n- Puppet Agent 3.8.5\r\n- CUPS 2.1.3-4.\r\n\r\n**init.pp**\r\n```\r\nclass cups_print (\r\n  $add_printer  = {},\r\n  ){\r\ninclude cups\r\n\r\n## Need for custom config settings\r\n  file { '/etc/cups/cupsd.conf':\r\n    ensure  => 'file',\r\n    owner   => 'root',\r\n    group   => 'lp',\r\n    mode    => '0644',\r\n    source  => 'puppet:///modules/cups_print/etc/cups/cupsd.conf',\r\n    require => Package['cups'],\r\n    notify  => Service['cups'],\r\n  }\r\n\r\n## Need this otherwise cups stops running after 6 minutes ## would like better work around\r\n  file { '/lib/systemd/system/cups.socket':\r\n    source  => 'puppet:///modules/cups_print/etc/cups/cups.socket',\r\n    require => Package[ 'cups' ],\r\n    mode    => '0644',\r\n    owner   => 'root',\r\n    notify  => Service['cups'],\r\n  }\r\n## Using nginx for PAM/Cups Authentication\r\n  file { '/etc/pam.d/nginx':\r\n    ensure  => 'file',\r\n    path    => '/etc/pam.d/nginx',\r\n    content => '@include common-auth',\r\n  }\r\n  create_resources('cups_print::resource::add_printer', $add_printer )\r\n}\r\n```\r\n**cupsd.conf**\r\n```\r\nLogLevel info\r\nPort 631\r\nBrowsing Off\r\nDefaultAuthType None\r\nServerAlias *\r\nListen localhost:631\r\nDefaultEncryption Never ## use nginx for ssl\r\n\r\n<Location />\r\n\tAllow From All\r\n</Location>\r\n\r\n<Location /admin>\r\nOrder allow,deny\r\nAllow From All\r\n</Location>\r\n\r\n<Location /admin/conf>\r\nOrder allow,deny\r\nAllow From All\r\n</Location>\r\n\r\n# Only the owner or an administrator can cancel or authenticate a job...\r\n<Limit Cancel-Job CUPS-Authenticate-Job>\r\nRequire user @OWNER @SYSTEM\r\nOrder allow,deny\r\nAllow From All\r\n</Limit>\r\n```\r\n\r\n**add_printer.pp**\r\n```\r\n## define: cups_print::resource::add_printer\r\n## Add printers to system. Adapted for Hiera.\r\n\r\ndefine cups_print::resource::add_printer(\r\n  ## Variable names should be the same from cups.conf\r\n  $ensure       = $::cups_print::ensure,\r\n  $model        = $::cups_print::driver,\r\n  $connection   = $::cups_print::connection,\r\n  $accepting    = true, ## Default setting\r\n  $shared       = false, ## Default setting\r\n  $enabled      = true, ## Default setting\r\n  )\r\n  {\r\n\r\n  validate_re($ensure, '^(printer|class|absent)$',\r\n    \"${ensure} is not supported for ensure. Allowed values are 'printer', 'class', and 'absent'.\")\r\n\r\n    case $ensure {\r\n      'printer', default: {\r\n        cups_queue { $name:\r\n          ensure    => $ensure,\r\n          model     => $model,\r\n          uri       => $connection,\r\n          accepting => $accepting,\r\n          shared    => $shared,\r\n          enabled   => $enabled,\r\n        }\r\n      }\r\n#      'class':{} ##WIP\r\n#      'absent':{} ##WIP\r\n    }\r\n  }\r\n```\r\n\r\n**hierra: print.domain.com.yaml**\r\n```\r\n## Cups specific settings:\r\ncups_print::add_printer:\r\n  'HP-LaserJet-M506DN-243':\r\n    ensure: 'printer'\r\n    model: 'raw'\r\n    #model: 'drv:///sample.drv/generic.ppd'\r\n    connection: 'socket://172.16.0.243:9100'\r\n  'HP-LJP-P2055DN-202':\r\n    ensure: 'printer'\r\n    model: 'lsb/usr/cupsfilters/pxlmono.ppd'\r\n    connection: 'socket://172.16.0.202:9100'\r\n  'HP-LaserJet-M506-81':\r\n    ensure: 'printer'\r\n    model: 'lsb/usr/cupsfilters/pxlmono.ppd'\r\n    connection: 'socket://172.16.0.81:9100'\r\n  'WP-HP-LaserJet-M506-81':\r\n    ensure: 'absent'\r\n```\r\n\r\n** Issue**\r\nWhen puppet is run the printers get added every single time. This will be an problem when puppet is run as each printer appears to be deleted and then added. At that time a print job may fail. This seems to be an issue mostly when the /etc/cups/cupsd.conf file has been modified by puppet or the /lib/systemd/system/cups.socket file. When using default versions of those files, there does not seem to problem with puppet recreating printers. I am not sure how to work around this issue. \r\n\r\n**Error message**\r\n```\r\nDebug: Executing '/usr/sbin/lpadmin -E -p HP-LaserJet-M506DN-243 -v /dev/null'\r\nDebug: Executing '/usr/sbin/lpadmin -E -p HP-LaserJet-M506DN-243 -m raw'\r\nDebug: Executing '/usr/sbin/lpadmin -E -p HP-LaserJet-M506DN-243 -v socket://172.16.0.243:9100'\r\nDebug: Executing '/usr/sbin/lpadmin -E -p HP-LaserJet-M506DN-243 -o printer-is-shared=false'\r\nDebug: Cups_queue[HP-LaserJet-M506DN-243](provider=cups): Circumventing CUPS issue #4781 by temporarily allowing access for 'root'\r\nDebug: Executing '/usr/sbin/lpadmin -E -p HP-LaserJet-M506DN-243 -u allow:root'\r\nDebug: Executing '/usr/sbin/cupsenable -E HP-LaserJet-M506DN-243'\r\nDebug: Executing '/usr/sbin/lpadmin -E -p HP-LaserJet-M506DN-243 -u allow:all'\r\nDebug: Executing '/usr/sbin/cupsaccept -E HP-LaserJet-M506DN-243'\r\nNotice: /Stage[main]/cups_print/cups_print::Resource::Add_printer[HP-LaserJet-M506DN-243]/Cups_queue[HP-LaserJet-M506DN-243]/ensure: created a printer\r\nDebug: /Stage[main]/cups_print/cups_print::Resource::Add_printer[HP-LaserJet-M506DN-243]/Cups_queue[HP-LaserJet-M506DN-243]: The container cups_print::Resource::Add_printer[HP-LaserJet-M506DN-243] will propagate my refresh event\r\nDebug: cups_print::Resource::Add_printer[HP-LaserJet-M506DN-243]: The container Class[cups_print] will propagate my refresh event\r\nDebug: Class[cups_print]: The container Stage[main] will propagate my refresh event\r\n```\r\n\r\n```Shell\r\nroot@print:/etc/cups# puppet agent -t\r\nInfo: Retrieving pluginfacts\r\nInfo: Retrieving plugin\r\nInfo: Loading facts\r\nInfo: Caching catalog for signal-print.mbx.com\r\nInfo: Applying configuration version '1485546210'\r\nNotice: /Stage[main]/puppet/Exec[apt-update-puppet]/returns: executed successfully\r\nNotice: /Stage[main]/cups_print/cups_print::Resource::Add_printer[HP-LJP-P2055DN-202]/Cups_queue[HP-LJP-P2055DN-202]/ensure: created a printer\r\nNotice: /Stage[main]/cups_print/cups_print::Resource::Add_printer[HP-LaserJet-M506-81]/Cups_queue[HP-LaserJet-M506-81]/ensure: created a printer\r\nNotice: /Stage[main]/cups_print/cups_print::Resource::Add_printer[HP-LaserJet-M506DN-243]/Cups_queue[HP-LaserJet-M506DN-243]/ensure: created a printer\r\nNotice: Finished catalog run in 5.37 seconds\r\n```\r\n\r\nLet me know if anything stands out in my configuration or if you have any suggestions.\r\n"}}
{"actor":{"display_login":"lordbink"}}