1 | # copyright koumbit.org |
---|
2 | # Licence: GPL |
---|
3 | |
---|
4 | class cups::server { |
---|
5 | |
---|
6 | package { "cupsys": ensure => "installed" } |
---|
7 | |
---|
8 | file { "/etc/cups/cupsd.conf": |
---|
9 | source => "puppet:///cups/cupsd.conf", |
---|
10 | ensure => present, |
---|
11 | require => Package["cupsys"], |
---|
12 | owner => "root", group => "root", mode => "644", |
---|
13 | } |
---|
14 | |
---|
15 | # service { "cups": |
---|
16 | # enable => true, |
---|
17 | # ensure => running, |
---|
18 | # subscribe => [ Package["cupsys"], File["/etc/cups/cupsd.conf"] ], |
---|
19 | # } |
---|
20 | } |
---|
21 | |
---|
22 | define cups::printer ($printer, $p_deviceuri, $p_description, $p_location, $p_pathppd, $p_accept = "", $p_enable = "" ) |
---|
23 | { |
---|
24 | include cups::server |
---|
25 | |
---|
26 | exec { "cups_create_printer_$name": |
---|
27 | command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppd", |
---|
28 | path => "/bin:/sbin:/usr/sbin:/usr/bin", |
---|
29 | unless => "/bin/grep $printer /etc/cups/printers.conf", |
---|
30 | require => Package["cupsys"], |
---|
31 | } |
---|
32 | |
---|
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") |
---|
42 | } |
---|
43 | |
---|
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") |
---|
53 | } |
---|
54 | |
---|
55 | file { "/etc/cups/printers.conf": |
---|
56 | ensure => present, |
---|
57 | require => Package["cupsys"], |
---|
58 | owner => "root", group => "lp", mode => "600", |
---|
59 | } |
---|
60 | |
---|
61 | service { "cups": |
---|
62 | enable => true, |
---|
63 | ensure => running, |
---|
64 | subscribe => [ Package["cupsys"], File["/etc/cups/printers.conf"] ], |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | |
---|