From e6b9bb0a28e37a6905f65beee1f4c6c7f52a8c18 Mon Sep 17 00:00:00 2001 From: Lawrence Gohar Date: Thu, 12 May 2016 14:14:55 -0400 Subject: [PATCH 1/3] Adding support for cache_peer/cache_peer_access in init and templates. --- manifests/init.pp | 2 ++ templates/squid.conf.long.erb | 14 ++++++++++++++ templates/squid.conf.short.erb | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index e27a043..55e7749 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,6 +14,8 @@ $cache_mem = '256 MB', $cache_dir = [], $cache = [], + $cache_peer = [], + $cache_peer_access = [], $via = 'on', $ignore_expect_100 = 'off', $cache_mgr = 'root', diff --git a/templates/squid.conf.long.erb b/templates/squid.conf.long.erb index 8df1b62..acc3ae7 100644 --- a/templates/squid.conf.long.erb +++ b/templates/squid.conf.long.erb @@ -1189,6 +1189,20 @@ https_port <%= line %> <% end -%> <% end -%> +<% if @cache_peer -%> +# user-defined cache_peer +<% @cache_peer.each do |line| -%> +cache_peer <%= line %> +<% end -%> +<% end -%> + +<% if @cache_peer_access -%> +# user-defined cache_peer_access +<% @cache_peer_access.each do |line| -%> +cache_peer_access <%= line %> +<% end -%> +<% end -%> + # TAG: tcp_outgoing_tos # Allows you to select a TOS/Diffserv value to mark outgoing # connections with, based on the username or source address diff --git a/templates/squid.conf.short.erb b/templates/squid.conf.short.erb index c92f057..bf70abd 100644 --- a/templates/squid.conf.short.erb +++ b/templates/squid.conf.short.erb @@ -58,6 +58,20 @@ https_port <%= line %> <% end -%> <% end -%> +<% if @cache_peer -%> +# user-defined cache_peer +<% @cache_peer.each do |line| -%> +cache_peer <%= line %> +<% end -%> +<% end -%> + +<% if @cache_peer_access -%> +# user-defined cache_peer_access +<% @cache_peer_access.each do |line| -%> +cache_peer_access <%= line %> +<% end -%> +<% end -%> + # user-defined tcp_outgoing_addresses <% @tcp_outgoing_address.each do |line| -%> tcp_outgoing_address <%= line %> From 2e93c257e02dbbd15883f82051bb490da529fdbb Mon Sep 17 00:00:00 2001 From: Lawrence Gohar Date: Tue, 17 May 2016 13:01:24 -0400 Subject: [PATCH 2/3] Added icp_port to init and templates. --- manifests/init.pp | 1 + templates/squid.conf.long.erb | 6 ++++++ templates/squid.conf.short.erb | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 55e7749..9b6b81f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,6 +10,7 @@ $safe_ports = [ '80', '21', '443', '70', '210', '1025-65535', '280', '488', '591', '777', ], $http_access = [], $icp_access = [], + $icp_port = [], $tcp_outgoing_address = [], $cache_mem = '256 MB', $cache_dir = [], diff --git a/templates/squid.conf.long.erb b/templates/squid.conf.long.erb index acc3ae7..8420c12 100644 --- a/templates/squid.conf.long.erb +++ b/templates/squid.conf.long.erb @@ -4149,6 +4149,12 @@ server_persistent_connections <%= @server_persistent_connections %> # icp_port 3130 #Default: # icp_port 0 +<% if @icp_port -%> +# user-defined icp_port +<% @icp_port.each do |line| -%> +icp_port <%= line %> +<% end -%> +<% end -%> # TAG: htcp_port # The port number where Squid sends and receives HTCP queries to diff --git a/templates/squid.conf.short.erb b/templates/squid.conf.short.erb index bf70abd..6a28210 100644 --- a/templates/squid.conf.short.erb +++ b/templates/squid.conf.short.erb @@ -44,6 +44,13 @@ http_access deny all icp_access <%= line %> <% end -%> +<% if @icp_port -%> +# user-defined icp_port +<% @icp_port.each do |line| -%> +icp_port <%= line %> +<% end -%> +<% end -%> + <% if @http_port -%> # user-defined http_port <% @http_port.each do |line| -%> From a4cd1c22e239fb440deacb2b9fe60c9661ddc1a4 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Mon, 7 Nov 2016 17:11:12 -0500 Subject: [PATCH 3/3] Add support for Puppet v4 AIO * Add support for Puppet v4. * Add support for Ruby v2.3.1. * Explicitly test supported Puppet and Ruby version matrix. * Use strict variables. --- .fixtures.yml | 6 +-- .gitignore | 34 ++++++++++++++++- .travis.yml | 89 +++++++++++++++++++++++++++++++++++++++------ Gemfile | 43 +++++++++++++++------- Rakefile | 21 +++++++++-- manifests/init.pp | 7 ++-- manifests/params.pp | 1 - metadata.json | 14 +------ spec/spec_helper.rb | 27 ++++++++------ 9 files changed, 181 insertions(+), 61 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 431116f..861e0eb 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,7 +1,7 @@ fixtures: repositories: stdlib: - repo: "git://github.com/puppetlabs/puppetlabs-stdlib" - ref: "2.6.0" + repo: "https://github.com/puppetlabs/puppetlabs-stdlib.git" + ref: '4.6.0' symlinks: - squid3: "#{source_dir}" \ No newline at end of file + squid3: "#{source_dir}" diff --git a/.gitignore b/.gitignore index 2f6d24c..222e35e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,34 @@ -.idea +# Default .gitignore for Ruby +*.gem +*.rbc +.bundle +.config +coverage +InstalledFiles +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp +tmp + +# YARD artifacts +.yardoc +_yardoc +doc/ + +# Vim +*.swp + +# Eclipse +.project + +# OS X +.DS_Store + +# Puppet +coverage/ +spec/fixtures/manifests/* +spec/fixtures/modules/* Gemfile.lock diff --git a/.travis.yml b/.travis.yml index 31b66cb..5c07a5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,87 @@ --- -branches: - only: - - master language: ruby -before_install: - - gem update bundler - - bundle --version - - gem update --system 2.1.11 - - gem --version -bundler_args: --without development -script: "bundle exec rake spec SPEC_OPTS='--format documentation'" + rvm: - 1.8.7 - 1.9.3 - 2.0.0 + - 2.3.1 + env: matrix: + - PUPPET_GEM_VERSION="~> 3.1.0" + - PUPPET_GEM_VERSION="~> 3.2.0" - PUPPET_GEM_VERSION="~> 3.3.0" - - PUPPET_GEM_VERSION="~> 3.7.2" + - PUPPET_GEM_VERSION="~> 3.4.0" + - PUPPET_GEM_VERSION="~> 3.5.0" + - PUPPET_GEM_VERSION="~> 3.6.0" + - PUPPET_GEM_VERSION="~> 3.7.0" + - PUPPET_GEM_VERSION="~> 3.8.0" + - PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes" + - PUPPET_GEM_VERSION="~> 4.0.0" + - PUPPET_GEM_VERSION="~> 4.1.0" + - PUPPET_GEM_VERSION="~> 4.2.0" + - PUPPET_GEM_VERSION="~> 4.3.0" + - PUPPET_GEM_VERSION="~> 4.4.0" + - PUPPET_GEM_VERSION="~> 4.5.0" + - PUPPET_GEM_VERSION="~> 4.6.0" + - PUPPET_GEM_VERSION="~> 4.7.0" + - PUPPET_GEM_VERSION="~> 4.8.0" + - PUPPET_GEM_VERSION="~> 4" + +sudo: false + +before_install: + - 'gem update --system' + - 'gem update bundler' + +bundler_args: '--without acceptance' + +script: 'SPEC_OPTS="--format documentation" bundle exec rake validate lint spec' + +matrix: + fast_finish: true + exclude: + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.1.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.0.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.1.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.2.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.3.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.4.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.5.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.6.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.7.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4.8.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 4" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.1.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.2.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.3.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.4.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.5.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.6.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.7.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3.8.0" + - rvm: 2.3.1 + env: PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes" + notifications: - email: false \ No newline at end of file + email: false diff --git a/Gemfile b/Gemfile index fcb57ee..24dc838 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,9 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" -group :development, :test do - gem 'rake', :require => false - gem 'rspec-puppet', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'serverspec', :require => false - gem 'puppet-lint', :require => false - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false - gem 'pry', :require => false - gem 'simplecov', :require => false -end - if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else - gem 'facter', :require => false + gem 'facter', '>= 1.7.0', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] @@ -23,3 +11,32 @@ if puppetversion = ENV['PUPPET_GEM_VERSION'] else gem 'puppet', :require => false end + +gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false +gem 'rspec-puppet', :require => false +gem 'puppet-lint', '~> 2.0', :require => false +gem 'puppet-lint-absolute_classname-check', :require => false +gem 'puppet-lint-alias-check', :require => false +gem 'puppet-lint-empty_string-check', :require => false +gem 'puppet-lint-file_ensure-check', :require => false +gem 'puppet-lint-file_source_rights-check', :require => false +gem 'puppet-lint-leading_zero-check', :require => false +gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false +gem 'puppet-lint-trailing_comma-check', :require => false +gem 'puppet-lint-undef_in_function-check', :require => false +gem 'puppet-lint-unquoted_string-check', :require => false +gem 'puppet-lint-variable_contains_upcase', :require => false + +gem 'rspec', '~> 2.0', :require => false if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9' +gem 'rake', '~> 10.0', :require => false if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9' +gem 'json', '<= 1.8', :require => false if RUBY_VERSION < '2.0.0' +gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0' +gem 'metadata-json-lint', '0.0.11', :require => false if RUBY_VERSION < '1.9' +gem 'metadata-json-lint', :require => false if RUBY_VERSION >= '1.9' + +group :acceptance do + gem 'serverspec', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false + gem 'pry', :require => false +end diff --git a/Rakefile b/Rakefile index e5c2f6a..f2f0456 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,19 @@ -#!/usr/bin/env rake - -require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.relative = true +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] + +desc 'Validate manifests, templates, and ruby files' +task :validate do + Dir['manifests/**/*.pp'].each do |manifest| + sh "puppet parser validate --noop #{manifest}" + end + Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| + sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ + end + Dir['templates/**/*.erb'].each do |template| + sh "erb -P -x -T '-' #{template} | ruby -c" + end +end diff --git a/manifests/init.pp b/manifests/init.pp index d883a73..11a6825 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -73,15 +73,14 @@ } case $::osfamily { - 'FreeBSD': { $cmdpath = "/usr/local/sbin" } - default: { $cmdpath = "/usr/sbin" } + 'FreeBSD': { $cmdpath = '/usr/local/sbin' } + default: { $cmdpath = '/usr/sbin' } } - file { $config_file: + file { $::squid3::config_file: require => Package['squid3_package'], notify => Service['squid3_service'], content => template($use_template), validate_cmd => "${cmdpath}/${service_name} -k parse -f %", } - } diff --git a/manifests/params.pp b/manifests/params.pp index 41eca8f..dee9db3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -53,5 +53,4 @@ $access_log = [ "stdio:${log_directory}/access.log squid" ] $cache_log = "${log_directory}/cache.log" $cache_store_log = "stdio:${log_directory}/store.log" - } diff --git a/metadata.json b/metadata.json index 4a2d8d3..a49d673 100644 --- a/metadata.json +++ b/metadata.json @@ -27,19 +27,9 @@ } ], "requirements": [ - { - "name": "pe", - "version_requirement": "3.x" - }, - { - "name": "puppet", - "version_requirement": ">=2.7.20 <4.1.0" - } + {"name":"puppet","version_requirement":">= 3.0.0 < 5.0.0" } ], "dependencies": [ - { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 2.4.0" - } + {"name":"puppetlabs/stdlib","version_requirement":">= 4.0.0 < 5.0.0"} ] } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f5eef86..a82d3b1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,17 @@ require 'puppetlabs_spec_helper/module_spec_helper' - -RSpec.configure do |c| - - # Use color in STDOUT - c.color = true - - # Use color not only in STDOUT but also in pagers and files - c.tty = true - - # Use the specified formatter - c.formatter = :documentation # :progress, :html, :textmate -end \ No newline at end of file +RSpec.configure do |config| + config.hiera_config = 'spec/fixtures/hiera/hiera.yaml' + config.before :each do + # Ensure that we don't accidentally cache facts and environment between + # test cases. This requires each example group to explicitly load the + # facts being exercised with something like + # Facter.collection.loader.load(:ipaddress) + Facter.clear + Facter.clear_messages + end + config.default_facts = { + :environment => 'rp_env', + :operatingsystem => 'RedHat', + } +end