diff --git a/.github/README.md b/.github/README.md index 654c6d12..ac38c193 100644 --- a/.github/README.md +++ b/.github/README.md @@ -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. @@ -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. diff --git a/README.md.erb b/README.md.erb index d683bb60..20a4acca 100644 --- a/README.md.erb +++ b/README.md.erb @@ -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. @@ -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. diff --git a/manifests/init.pp b/manifests/init.pp index 2db26e24..ee486481 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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. @@ -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`. @@ -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 diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 64e70b7d..363a2841 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -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 } @@ -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 } diff --git a/templates/cupsd/_directives.erb b/templates/cupsd/_directives.erb index 4e984372..635b2b72 100644 --- a/templates/cupsd/_directives.erb +++ b/templates/cupsd/_directives.erb @@ -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| -%> @@ -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 %>"