Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ Installs, configures, and manages the CUPS service.

* `browsing`: Boolean value for the `Browsing` directive of the CUPS server. Defaults to `false`.

* `error_policy`: Specifies how a failed print job should behave.

* `default_queue`: The name of the default destination for all print jobs.
Requires the catalog to contain a `cups_queue` resource with the same name.

Expand Down Expand Up @@ -529,6 +531,8 @@ Installs, configures, and manages the CUPS service.

* `max_jobs`: Specifies the maximum number of jobs.

* `max_job_time`: Specifies the maximum time a job may take to print before it is canceled.

* `max_log_size`: Sets the `MaxLogSize` directive of the CUPS server.

* `max_request_size`: Specifies the maximum request/file size in bytes.
Expand Down
4 changes: 4 additions & 0 deletions README.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ Installs, configures, and manages the CUPS service.

* `browsing`: Boolean value for the `Browsing` directive of the CUPS server. Defaults to `false`.

* `error_policy`: Specifies how a failed print job should behave.

* `default_queue`: The name of the default destination for all print jobs.
Requires the catalog to contain a `cups_queue` resource with the same name.

Expand Down Expand Up @@ -531,6 +533,8 @@ Installs, configures, and manages the CUPS service.

* `max_jobs`: Specifies the maximum number of jobs.

* `max_job_time`: Specifies the maximum time a job may take to print before it is canceled.

* `max_log_size`: Sets the `MaxLogSize` directive of the CUPS server.

* `max_request_size`: Specifies the maximum request/file size in bytes.
Expand Down
68 changes: 36 additions & 32 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# Accepts a string or an array of supported protocols.
# @param browse_web_if Boolean value for the `BrowseWebIF` directive of the CUPS server.
# @param browsing Boolean value for the `Browsing` directive of the CUPS server.
# @param error_policy Specifies how a failed print job should behave.
# @param default_queue The name of the default destination for all print jobs.
# Requires the catalog to contain a `cups_queue` resource with the same name.
# @param listen Which addresses to the CUPS daemon should listen to.
Expand All @@ -43,6 +44,7 @@
# @param max_clients Specifies the maximum number of simultaneous clients to support.
# @param max_clients_per_host Specifies the maximum number of simultaneous clients to support from a single address.
# @param max_jobs Specifies the maximum number of jobs.
# @param max_job_time Specifies the maximum time a job may take to print before it is canceled.
# @param max_log_size Sets the `MaxLogSize` directive of the CUPS server.
# @param max_request_size Specifies the maximum request/file size in bytes.
# @param package_ensure Whether CUPS packages should be `present` or `absent`.
Expand All @@ -65,38 +67,40 @@
# @param web_interface Boolean value to enable or disable the server's web interface.
#
class cups (
Optional[String] $access_log_level = undef,
Optional[Variant[String, Array[String]]] $browse_dnssd_subtypes = undef,
Optional[Variant[String, Array[String]]] $browse_local_protocols = undef,
Optional[Boolean] $browse_web_if = undef,
Boolean $browsing = false,
Optional[String] $default_queue = undef,
Variant[String, Array[String]] $listen = ['localhost:631', '/var/run/cups/cups.sock'],
Optional[Variant[String, Hash]] $location = undef,
Optional[Integer] $log_debug_history = undef,
Optional[String] $log_level = undef,
Optional[String] $log_time_format = undef,
Optional[Integer] $max_clients = undef,
Optional[Integer] $max_clients_per_host = undef,
Optional[Integer] $max_jobs = undef,
Optional[Variant[Integer, String]] $max_log_size = undef,
Optional[Integer] $max_request_size = undef,
String $package_ensure = 'present',
Boolean $package_manage = true,
Variant[String, Array[String]] $package_names = $::cups::params::package_names,
Optional[String] $page_log_format = undef,
Optional[String] $papersize = undef,
Optional[Variant[Integer, String]] $preserve_job_files = undef,
Optional[Variant[Integer, String]] $preserve_job_history = undef,
Boolean $purge_unmanaged_queues = false,
Optional[Hash] $resources = undef,
Optional[Variant[String, Array[String]]] $server_alias = undef,
Optional[String] $server_name = undef,
Boolean $service_enable = true,
String $service_ensure = 'running',
Boolean $service_manage = true,
Variant[String, Array[String]] $service_names = 'cups',
Optional[Boolean] $web_interface = undef,
Optional[String] $access_log_level = undef,
Optional[Variant[String, Array[String]]] $browse_dnssd_subtypes = undef,
Optional[Variant[String, Array[String]]] $browse_local_protocols = undef,
Optional[Boolean] $browse_web_if = undef,
Boolean $browsing = false,
Optional[Enum['abort-job','retry-current-job','retry-job','stop-printer']] $error_policy = undef,
Optional[String] $default_queue = undef,
Variant[String, Array[String]] $listen = ['localhost:631', '/var/run/cups/cups.sock'],
Optional[Variant[String, Hash]] $location = undef,
Optional[Integer] $log_debug_history = undef,
Optional[String] $log_level = undef,
Optional[String] $log_time_format = undef,
Optional[Integer] $max_clients = undef,
Optional[Integer] $max_clients_per_host = undef,
Optional[Integer] $max_jobs = undef,
Optional[Integer] $max_job_time = undef,
Optional[Variant[Integer, String]] $max_log_size = undef,
Optional[Integer] $max_request_size = undef,
String $package_ensure = 'present',
Boolean $package_manage = true,
Variant[String, Array[String]] $package_names = $::cups::params::package_names,
Optional[String] $page_log_format = undef,
Optional[String] $papersize = undef,
Optional[Variant[Integer, String]] $preserve_job_files = undef,
Optional[Variant[Integer, String]] $preserve_job_history = undef,
Boolean $purge_unmanaged_queues = false,
Optional[Hash] $resources = undef,
Optional[Variant[String, Array[String]]] $server_alias = undef,
Optional[String] $server_name = undef,
Boolean $service_enable = true,
String $service_ensure = 'running',
Boolean $service_manage = true,
Variant[String, Array[String]] $service_names = 'cups',
Optional[Boolean] $web_interface = undef,
) inherits cups::params {

contain cups::packages
Expand Down
36 changes: 36 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,28 @@
end
end

describe 'error_policy' do
let(:facts) { any_supported_os }

context 'when not set' do
let(:params) { {} }

it { is_expected.to_not contain_file('/etc/cups/cupsd.conf').with(content: /^ErrorPolicy/) }
end

context 'when set to true' do
let(:params) { { error_policy: 'abort-job' } }

it { is_expected.to contain_file('/etc/cups/cupsd.conf').with(content: /^ErrorPolicy abort-job$/) }
end

context 'when set to false' do
let(:params) { { error_policy: 'stop-printer' } }

it { is_expected.to contain_file('/etc/cups/cupsd.conf').with(content: /^ErrorPolicy stop-printer$/) }
end
end

describe 'default_queue' do
let(:facts) { any_supported_os }

Expand Down Expand Up @@ -377,6 +399,20 @@
end
end

describe 'max_job_time' do
let(:facts) { any_supported_os }

context 'when not set' do
it { is_expected.to_not contain_file('/etc/cups/cupsd.conf').with(content: /^MaxJobTime/) }
end

context 'when set to 900' do
let(:params) { { max_job_time: 900 } }

it { is_expected.to contain_file('/etc/cups/cupsd.conf').with(content: /^MaxJobTime 900$/) }
end
end


describe 'max_log_size' do
let(:facts) { any_supported_os }
Expand Down
2 changes: 2 additions & 0 deletions templates/cupsd/_directives.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<%= COMMENT_OUT if @browse_local_protocols.nil? -%>BrowseLocalProtocols <%= @browse_local_protocols.is_a?(Array) ? @browse_local_protocols.join(' ') : @browse_local_protocols %>
<%= COMMENT_OUT if @browse_web_if.nil? -%>BrowseWebIF <%= (@browse_web_if ? 'Yes' : 'No') %>
<%= COMMENT_OUT if @browsing.nil? -%>Browsing <%= (@browsing ? 'Yes' : 'No') %>
<%= COMMENT_OUT if @error_policy.nil? -%>ErrorPolicy <%= @error_policy %>
DefaultAuthType Basic
<% unless @listen.empty? -%>
<% [@listen].flatten.each do |l| -%>
Expand All @@ -16,6 +17,7 @@ DefaultAuthType Basic
<%= COMMENT_OUT if @max_clients.nil? -%>MaxClients <%= @max_clients %>
<%= COMMENT_OUT if @max_clients_per_host.nil? -%>MaxClientsPerHost <%= @max_clients_per_host %>
<%= COMMENT_OUT if @max_jobs.nil? -%>MaxJobs <%= @max_jobs %>
<%= COMMENT_OUT if @max_job_time.nil? -%>MaxJobTime <%= @max_job_time %>
<%= COMMENT_OUT if @max_log_size.nil? -%>MaxLogSize <%= @max_log_size %>
<%= COMMENT_OUT if @max_request_size.nil? -%>MaxRequestSize <%= @max_request_size %>
<%= COMMENT_OUT if @page_log_format.nil? -%>PageLogFormat "<%= @page_log_format %>"
Expand Down
Loading