[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 | |
---|
[463] | 22 | define cups::printer ($printer, $p_description, $p_deviceuri, $p_pathppd) |
---|
| 23 | { |
---|
| 24 | include cups::server |
---|
| 25 | |
---|
| 26 | exec { "cups_create_printer_$name": |
---|
[464] | 27 | command => "lpadmin -p $printer -D '$p_description' -v $p_deviceuri -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 | |
---|
[464] | 33 | exec { "cupsaccept_$name": |
---|
| 34 | command => "cupsaccept $printer", |
---|
| 35 | path => "/bin:/sbin:/usr/sbin:/usr/bin", |
---|
| 36 | # unless => "/bin/grep -v $printer /etc/cups/printers.conf", |
---|
| 37 | require => exec["cups_create_printer_$name"], |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | exec { "cupsenable_$name": |
---|
| 41 | command => "cupsenable $printer", |
---|
| 42 | path => "/bin:/sbin:/usr/sbin:/usr/bin", |
---|
| 43 | # unless => "/bin/grep -v $printer /etc/cups/printers.conf", |
---|
| 44 | require => exec["cups_create_printer_$name"], |
---|
| 45 | } |
---|
| 46 | |
---|
[463] | 47 | file { "/etc/cups/printers.conf": |
---|
| 48 | ensure => present, |
---|
| 49 | require => Package["cupsys"], |
---|
| 50 | owner => "root", group => "lp", mode => "600", |
---|
| 51 | } |
---|
| 52 | |
---|
[464] | 53 | service { "cups": |
---|
[463] | 54 | enable => true, |
---|
| 55 | ensure => running, |
---|
| 56 | subscribe => [ Package["cupsys"], File["/etc/cups/printers.conf"] ], |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | |
---|