[417] | 1 | # copyright koumbit.org |
---|
| 2 | # Licence: GPL |
---|
| 3 | |
---|
[463] | 4 | class cups::server { |
---|
[417] | 5 | |
---|
| 6 | package { "cupsys": ensure => "installed" } |
---|
| 7 | |
---|
[443] | 8 | file { "/etc/cups/cupsd.conf": |
---|
[464] | 9 | source => "puppet:///cups/cupsd.conf", |
---|
[419] | 10 | ensure => present, |
---|
| 11 | require => Package["cupsys"], |
---|
| 12 | owner => "root", group => "root", mode => "644", |
---|
| 13 | } |
---|
| 14 | |
---|
[464] | 15 | # service { "cups": |
---|
| 16 | # enable => true, |
---|
| 17 | # ensure => running, |
---|
| 18 | # subscribe => [ Package["cupsys"], File["/etc/cups/cupsd.conf"] ], |
---|
| 19 | # } |
---|
[417] | 20 | } |
---|
[419] | 21 | |
---|
[468] | 22 | define cups::printer ($printer, $p_deviceuri, $p_description, $p_location, $p_pathppd, $p_accept = "", $p_enable = "" ) |
---|
[463] | 23 | { |
---|
| 24 | include cups::server |
---|
| 25 | |
---|
| 26 | exec { "cups_create_printer_$name": |
---|
[468] | 27 | command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppd", |
---|
[463] | 28 | path => "/bin:/sbin:/usr/sbin:/usr/bin", |
---|
| 29 | unless => "/bin/grep $printer /etc/cups/printers.conf", |
---|
| 30 | require => Package["cupsys"], |
---|
| 31 | } |
---|
| 32 | |
---|
[468] | 33 | if $p_accept { |
---|
| 34 | exec { "cupsaccept_$name": |
---|
| 35 | command => "cupsaccept $printer", |
---|
| 36 | path => "/bin:/sbin:/usr/sbin:/usr/bin", |
---|
| 37 | unless => "grep -A8 $printer /etc/cups/printers.conf | grep 'Accepting Yes'", |
---|
| 38 | require => exec["cups_create_printer_$name"], |
---|
| 39 | } |
---|
| 40 | } else { |
---|
| 41 | debug ("'$printer' will not accept print jobs") |
---|
[464] | 42 | } |
---|
| 43 | |
---|
[468] | 44 | if $p_enable { |
---|
| 45 | exec { "cupsenable_$name": |
---|
| 46 | command => "cupsenable $printer", |
---|
| 47 | path => "/bin:/sbin:/usr/sbin:/usr/bin", |
---|
| 48 | unless => "grep -A5 $printer /etc/cups/printers.conf | grep 'State Idle'", |
---|
| 49 | require => exec["cups_create_printer_$name"], |
---|
| 50 | } |
---|
| 51 | } else { |
---|
| 52 | debug ("'$printer' is disabled") |
---|
[464] | 53 | } |
---|
| 54 | |
---|
[463] | 55 | file { "/etc/cups/printers.conf": |
---|
| 56 | ensure => present, |
---|
| 57 | require => Package["cupsys"], |
---|
| 58 | owner => "root", group => "lp", mode => "600", |
---|
| 59 | } |
---|
| 60 | |
---|
[464] | 61 | service { "cups": |
---|
[463] | 62 | enable => true, |
---|
| 63 | ensure => running, |
---|
| 64 | subscribe => [ Package["cupsys"], File["/etc/cups/printers.conf"] ], |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|