source: trunk/puppet/modules/puppet-cups/manifests/init.pp @ 707

Last change on this file since 707 was 572, checked in by sebas@…, 15 years ago

agrego aca la class cups::browse para los clientes que tiene que ver la impresoras remotas

File size: 5.9 KB
RevLine 
[417]1# copyright koumbit.org
2# Licence: GPL
3
[471]4class cups {
[473]5}
[471]6
[572]7##
8## cups (browse) - to see other printers
9##
10
11class cups::browse {
12
13    package { [ 'cups' ]: ensure => installed }
14
15    file { "/etc/cups/cupsd.conf": ensure => present, checksum => mtime }
16   
17    line { cupsbrowseoff:
18       file => "/etc/cups/cupsd.conf",
19       line => 'Browsing Off',
20       ensure => absent,
21       require => Package["cups"]
22    }
23    line { cupsbrowseon:
24       file => "/etc/cups/cupsd.conf",
25       line => 'Browsing On',
26       ensure => present,
27       require => Package["cups"]
28    }
29
30    service { "cups":
31       enable => true,
32       ensure => running,
33       subscribe => [ Package["cups"], File["/etc/cups/cupsd.conf"] ],
34    }
35}
36
37
[478]38define cups::saned::client ($remotescanner)
39  {
40   package { "xsane": ensure => "installed" }
[514]41   package { "gocr-tk": ensure => "installed" }
[478]42
43   file { "/etc/sane.d/net.conf":
44      ensure => present,
45      require => Package["xsane"],
46      owner => "root", group => "root", mode => "644",
47   }
48    line { saned_remotescanner:
49      file => "/etc/sane.d/net.conf",
50      line => $remotescanner,
51      ensure => present,
52      require => Package["xsane"],
53    }
54  }
55
[473]56class cups::saned {
57
58   package { "sane-utils": ensure => "installed" }
59
[476]60    line { saned_activate_off:
61      file => "/etc/default/saned",
62      line => 'RUN=no',
63      ensure => absent,
64      require => Package["sane-utils"],
65      notify  => Service["saned"],
66    }
67    line { saned_activate_on:
68      file => "/etc/default/saned",
69      line => 'RUN=yes',
70      ensure => present,
71      require => Package["sane-utils"],
72      notify  => Service["saned"],
73    }
74
[473]75   file { "/etc/default/saned":
76      ensure => present,
77      require => Package["sane-utils"],
78      owner => "root", group => "root", mode => "644",
79   }
80
[478]81    line { saned_allow:
82      file => "/etc/sane.d/saned.conf",
83      line => $sanedallow,
84      ensure => present,
85      require => Package["sane-utils"],
86      notify  => Service["saned"],
87    }
88
89   file { "/etc/sane.d/saned.conf":
90      ensure => present,
91      require => Package["sane-utils"],
92      owner => "root", group => "root", mode => "644",
93   }
94
[472]95   service { "saned":
[473]96      enable => true,
97      ensure => running,
[476]98      provider => "debian",
[473]99      subscribe => [ Package["sane-utils"], File["/etc/default/saned"] ],
[472]100   }
[474]101
102   @user { "saned":
103        ensure  => "present",
104        groups  => "lp",
105        require => Package["sane-utils"],
106   }
107
108   realize(
109        User["saned"]
110   )
111
[471]112}
113
[463]114class cups::server {
[417]115
116   package { "cupsys": ensure => "installed" }
[469]117   package { [ "hplip", "hpijs-ppds" ]: ensure => installed; }
[417]118
[443]119   file { "/etc/cups/cupsd.conf":
[464]120      source => "puppet:///cups/cupsd.conf",
[419]121      ensure => present,
122      require => Package["cupsys"],
123      owner => "root", group => "root", mode => "644",
124   }
125
[469]126   file { "/etc/cups/printers.conf":
127      ensure => present,
128      require => Package["cupsys"],
129      owner => "root", group => "lp", mode => "600",
130   }
[475]131
132   service { "cups":
133      enable => true,
134      ensure => running,
[476]135      provider => "debian",
[475]136      subscribe => [ Package["cupsys"], File["/etc/cups/cupsd.conf"] ],
137   }
[417]138}
[419]139
[471]140define cups::printer ($printer, $p_deviceuri, $p_description, $p_location, $p_pathppd = "", $p_ppd = "", $p_filter = "", $p_accept = "", $p_enable = "", $p_scan = "" )
[463]141 {
142   include cups::server
143
[469]144  if $p_pathppd {
145    exec { "cups_create_printer_$name":
146      command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppd",
147      path => "/bin:/sbin:/usr/sbin:/usr/bin",
148      unless => "/bin/grep $printer /etc/cups/printers.conf",
[476]149      require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"], Service["cups"]],
[469]150    }
151  } else {
152     file { "/etc/cups/ppd/$p_ppd":
153     ensure => present,
154     owner => "root", group => "root", mode => "644",
155     source  => "puppet:///files/cups/$name/$p_ppd",
156     require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"]],
157    }
158    $p_pathppdd = "/etc/cups/ppd/"
159
160    exec { "cups_create_printer_$name":
161      command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppdd$p_ppd",
162      path => "/bin:/sbin:/usr/sbin:/usr/bin",
163      unless => "/bin/grep $printer /etc/cups/printers.conf",
164      require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"]],
165    }
[463]166  }
167
[469]168  if $p_filter {
169     file { "/usr/lib/cups/filter/$p_filter":
170     ensure => present,
171     owner => "root", group => "root", mode => "755",
172     source  => "puppet:///files/cups/$name/$p_filter",
173     require => exec["cups_create_printer_$name"],
174    }
175  } else {
176    debug ("'$printer' doesn't need a special filter")
177  }
178
[468]179  if $p_accept {
180    exec { "cupsaccept_$name":
181      command => "cupsaccept $printer",
182      path => "/bin:/sbin:/usr/sbin:/usr/bin",
183      unless => "grep -A8 $printer /etc/cups/printers.conf | grep 'Accepting Yes'",
184      require => exec["cups_create_printer_$name"],
185    }
186  } else {
[477]187    exec { "cupsreject_$name":
188      command => "cupsreject $printer",
189      path => "/bin:/sbin:/usr/sbin:/usr/bin",
190      unless => "grep -A8 $printer /etc/cups/printers.conf | grep 'Accepting No'",
191      require => exec["cups_create_printer_$name"],
192    }
[468]193    debug ("'$printer' will not accept print jobs")
[464]194  }
195
[468]196  if $p_enable {
197    exec { "cupsenable_$name":
198      command => "cupsenable $printer",
199      path => "/bin:/sbin:/usr/sbin:/usr/bin",
200      unless => "grep -A5 $printer /etc/cups/printers.conf | grep 'State Idle'",
201      require => exec["cups_create_printer_$name"],
202    }
203  } else {
[477]204    exec { "cupsdisable_$name":
205      command => "cupsdisable $printer",
206      path => "/bin:/sbin:/usr/sbin:/usr/bin",
207      unless => "grep -A5 $printer /etc/cups/printers.conf | grep 'State Stopped'",
208      require => exec["cups_create_printer_$name"],
209    }
[468]210    debug ("'$printer' is disabled")
[464]211  }
212
[471]213  if $p_scan {
[473]214    include cups::saned
[471]215  } else {
216    debug ("'$printer' cannot scan on the network")
217  }
218
[463]219}
220
Note: See TracBrowser for help on using the repository browser.