Index: trunk/puppet/modules/puppet-cups/files/cupsd.conf
===================================================================
--- trunk/puppet/modules/puppet-cups/files/cupsd.conf	(revision 481)
+++ trunk/puppet/modules/puppet-cups/files/cupsd.conf	(revision 481)
@@ -0,0 +1,51 @@
+LogLevel warning
+SystemGroup lpadmin
+# Allow remote access
+Port 631
+Listen /var/run/cups/cups.sock
+# Enable printer sharing and shared printers.
+Browsing On
+BrowseOrder allow,deny
+BrowseAddress @LOCAL
+DefaultAuthType Basic
+<Location />
+  # Allow shared printing and remote administration...
+  Order allow,deny
+  Allow all
+</Location>
+<Location /admin>
+  Encryption Required
+  # Allow remote administration...
+  Order allow,deny
+  Allow all
+</Location>
+<Location /admin/conf>
+  AuthType Default
+  Require user @SYSTEM
+  # Allow remote access to the configuration files...
+  Order allow,deny
+  Allow all
+</Location>
+<Policy default>
+  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
+    Require user @OWNER @SYSTEM
+    Order deny,allow
+  </Limit>
+  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
+    AuthType Default
+    Require user @SYSTEM
+    Order deny,allow
+  </Limit>
+  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
+    AuthType Default
+    Require user @SYSTEM
+    Order deny,allow
+  </Limit>
+  <Limit CUPS-Authenticate-Job>
+    Require user @OWNER @SYSTEM
+    Order deny,allow
+  </Limit>
+  <Limit All>
+    Order deny,allow
+  </Limit>
+</Policy>
Index: trunk/puppet/modules/puppet-cups/manifests/init.pp
===================================================================
--- trunk/puppet/modules/puppet-cups/manifests/init.pp	(revision 481)
+++ trunk/puppet/modules/puppet-cups/manifests/init.pp	(revision 481)
@@ -0,0 +1,188 @@
+# copyright koumbit.org
+# Licence: GPL
+
+class cups {
+}
+
+define cups::saned::client ($remotescanner)
+  {
+   package { "xsane": ensure => "installed" }
+
+   file { "/etc/sane.d/net.conf":
+      ensure => present,
+      require => Package["xsane"],
+      owner => "root", group => "root", mode => "644",
+   }
+    line { saned_remotescanner:
+      file => "/etc/sane.d/net.conf",
+      line => $remotescanner,
+      ensure => present,
+      require => Package["xsane"],
+    }
+  }
+
+class cups::saned {
+
+   package { "sane-utils": ensure => "installed" }
+
+    line { saned_activate_off:
+      file => "/etc/default/saned",
+      line => 'RUN=no',
+      ensure => absent,
+      require => Package["sane-utils"],
+      notify  => Service["saned"],
+    }
+    line { saned_activate_on:
+      file => "/etc/default/saned",
+      line => 'RUN=yes',
+      ensure => present,
+      require => Package["sane-utils"],
+      notify  => Service["saned"],
+    }
+
+   file { "/etc/default/saned":
+      ensure => present,
+      require => Package["sane-utils"],
+      owner => "root", group => "root", mode => "644",
+   }
+
+    line { saned_allow:
+      file => "/etc/sane.d/saned.conf",
+      line => $sanedallow,
+      ensure => present,
+      require => Package["sane-utils"],
+      notify  => Service["saned"],
+    }
+
+   file { "/etc/sane.d/saned.conf":
+      ensure => present,
+      require => Package["sane-utils"],
+      owner => "root", group => "root", mode => "644",
+   }
+
+   service { "saned":
+      enable => true,
+      ensure => running,
+      provider => "debian",
+      subscribe => [ Package["sane-utils"], File["/etc/default/saned"] ],
+   }
+
+   @user { "saned":
+        ensure  => "present",
+        groups  => "lp",
+        require => Package["sane-utils"],
+   }
+
+   realize(
+        User["saned"]
+   )
+
+}
+
+class cups::server {
+
+   package { "cupsys": ensure => "installed" }
+   package { [ "hplip", "hpijs-ppds" ]: ensure => installed; }
+
+   file { "/etc/cups/cupsd.conf":
+      source => "puppet:///cups/cupsd.conf",
+      ensure => present,
+      require => Package["cupsys"],
+      owner => "root", group => "root", mode => "644",
+   }
+
+   file { "/etc/cups/printers.conf":
+      ensure => present,
+      require => Package["cupsys"],
+      owner => "root", group => "lp", mode => "600",
+   }
+
+   service { "cups":
+      enable => true,
+      ensure => running,
+      provider => "debian",
+      subscribe => [ Package["cupsys"], File["/etc/cups/cupsd.conf"] ],
+   }
+}
+
+define cups::printer ($printer, $p_deviceuri, $p_description, $p_location, $p_pathppd = "", $p_ppd = "", $p_filter = "", $p_accept = "", $p_enable = "", $p_scan = "" )
+ {
+   include cups::server
+
+  if $p_pathppd {
+    exec { "cups_create_printer_$name":
+      command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppd",
+      path => "/bin:/sbin:/usr/sbin:/usr/bin",
+      unless => "/bin/grep $printer /etc/cups/printers.conf",
+      require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"], Service["cups"]],
+    }
+  } else {
+     file { "/etc/cups/ppd/$p_ppd":
+     ensure => present,
+     owner => "root", group => "root", mode => "644",
+     source  => "puppet:///files/cups/$name/$p_ppd",
+     require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"]],
+    }
+    $p_pathppdd = "/etc/cups/ppd/"
+
+    exec { "cups_create_printer_$name":
+      command => "lpadmin -p $printer -v $p_deviceuri -D '$p_description' -L '$p_location' -P $p_pathppdd$p_ppd",
+      path => "/bin:/sbin:/usr/sbin:/usr/bin",
+      unless => "/bin/grep $printer /etc/cups/printers.conf",
+      require => [Package["cupsys"], Package["hplip"], Package["hpijs-ppds"]],
+    }
+  }
+
+  if $p_filter {
+     file { "/usr/lib/cups/filter/$p_filter":
+     ensure => present,
+     owner => "root", group => "root", mode => "755",
+     source  => "puppet:///files/cups/$name/$p_filter",
+     require => exec["cups_create_printer_$name"],
+    }
+  } else {
+    debug ("'$printer' doesn't need a special filter")
+  }
+
+  if $p_accept {
+    exec { "cupsaccept_$name":
+      command => "cupsaccept $printer",
+      path => "/bin:/sbin:/usr/sbin:/usr/bin",
+      unless => "grep -A8 $printer /etc/cups/printers.conf | grep 'Accepting Yes'",
+      require => exec["cups_create_printer_$name"],
+    }
+  } else {
+    exec { "cupsreject_$name":
+      command => "cupsreject $printer",
+      path => "/bin:/sbin:/usr/sbin:/usr/bin",
+      unless => "grep -A8 $printer /etc/cups/printers.conf | grep 'Accepting No'",
+      require => exec["cups_create_printer_$name"],
+    }
+    debug ("'$printer' will not accept print jobs")
+  }
+
+  if $p_enable {
+    exec { "cupsenable_$name":
+      command => "cupsenable $printer",
+      path => "/bin:/sbin:/usr/sbin:/usr/bin",
+      unless => "grep -A5 $printer /etc/cups/printers.conf | grep 'State Idle'",
+      require => exec["cups_create_printer_$name"],
+    }
+  } else {
+    exec { "cupsdisable_$name":
+      command => "cupsdisable $printer",
+      path => "/bin:/sbin:/usr/sbin:/usr/bin",
+      unless => "grep -A5 $printer /etc/cups/printers.conf | grep 'State Stopped'",
+      require => exec["cups_create_printer_$name"],
+    }
+    debug ("'$printer' is disabled")
+  }
+
+  if $p_scan {
+    include cups::saned
+  } else {
+    debug ("'$printer' cannot scan on the network")
+  }
+
+}
+
