Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Wait for CUPS to listen on port 631. Fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
tequeter authored and leoarnold committed Apr 15, 2019
1 parent abb371c commit c593ead
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
fixtures:
repositories:
stdlib: # dependency of camptocamp-systemd
repo: "https://github.com/puppetlabs/puppetlabs-stdlib"
ref: "4.13.1"
systemd:
repo: "https://github.com/camptocamp/puppet-systemd"
ref: "1.0.0"
symlinks:
cups: "#{source_dir}"

16 changes: 16 additions & 0 deletions manifests/server/services.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,26 @@
class cups::server::services inherits cups::server {

if ($::cups::service_manage) {

service { $::cups::service_names :
ensure => $::cups::service_ensure,
enable => $::cups::service_enable,
}

if ($::systemd) {

systemd::dropin_file { 'wait_until_cups_listens_on_port_631.conf':
unit => 'cups.socket',
content => template(
'cups/_header.erb',
'cups/systemd/wait_until_cups_listens_on_port_631.conf.erb'
)
}

Systemd::Dropin_file['wait_until_cups_listens_on_port_631.conf'] ~> Service[$::cups::service_names]

}

}

}
7 changes: 5 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"printing"
],
"dependencies": [

{
"name": "camptocamp-systemd",
"version_requirement": ">= 1.0.0 < 3.0.0"
}
],
"operatingsystem_support": [
{
Expand Down Expand Up @@ -92,7 +95,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.0.0 < 7.0.0"
"version_requirement": ">= 4.10.0 < 7.0.0"
}
],
"data_provider": null,
Expand Down
36 changes: 36 additions & 0 deletions spec/acceptance/classes/server_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

RSpec.describe 'Including class "cups"' do
before(:all) do
ensure_cups_is_running
purge_all_queues
end

let(:manifest) { "include '::cups'" }

describe 'restarting the CUPS server' do
before(:all) do
# Trigger a restart of the Class[cups::server::service] through Class[cups::server::config]
shell('touch /etc/cups/lpoptions')
end

context 'when there are a lot of queues present' do
before(:all) do
names = (1..100).map { |n| "Queue#{n.to_s.rjust(3, '0')}" }

# Increase RAM on virtual machine if this command runs suspiciously slow
add_printers(*names)
end

it 'applies without error' do
apply_manifest(manifest)
end

it 'is idempotent' do
apply_manifest(manifest, catch_changes: true)
end
end
end
end
4 changes: 2 additions & 2 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
describe 'package_manage' do
context 'when set to true' do
context 'with default package_names' do
on_supported_os.each do |os, facts|
on_supported_os(systemd: true).each do |os, facts|
%w[present absent].each do |package_ensure|
context "when package_ensure => #{package_ensure}" do
let(:params) { { package_ensure: package_ensure, package_manage: true } }
Expand Down Expand Up @@ -408,7 +408,7 @@
let(:params) { { package_manage: false } }

context 'with default package_names' do
on_supported_os.each do |os, facts|
on_supported_os(systemd: true).each do |os, facts|
context "on #{os}" do
let(:facts) { facts }

Expand Down
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@

require 'rspec-puppet-facts'
include RspecPuppetFacts # rubocop:disable Style/MixinUsage
add_custom_fact :systemd, true

def any_supported_os(morefacts = {})
{
operatingsystem: 'CentOS',
osfamily: 'Suse',
os: { 'family' => 'Suse', 'name' => 'CentOS' }
}.merge(morefacts)
FacterDB
.get_facts(osfamily: 'Debian', operatingsystem: 'Ubuntu', lsbdistcodename: 'bionic')
.max_by { |facts| Gem::Version.new(facts[:facterversion]) }
.merge(morefacts)
end

# RSpec-Puppet configuration
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
hosts.each do |host|
shell("sed -i 's/^nameserver.*/nameserver 8.8.8.8/' /etc/resolv.conf")
install_puppet_agent_on(host, puppet_collection: 'puppet6')
install_puppet_module_via_pmt_on(host, module_name: 'camptocamp-systemd', version: '1.0.0')
copy_module_to(host, module_name: 'cups', source: project_root, target_module_path: '/etc/puppetlabs/code/modules')
scp_to(host, File.join(project_root, 'spec/fixtures/ppd/textonly.ppd'), '/tmp/')
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Socket]
ListenStream=[::1]:631

0 comments on commit c593ead

Please sign in to comment.