Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puppet4 #52

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -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}"
squid3: "#{source_dir}"
34 changes: 33 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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
89 changes: 77 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
email: false
43 changes: 30 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
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']
gem 'puppet', puppetversion, :require => false
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
21 changes: 18 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
$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 = [],
$cache = [],
$cache_peer = [],
$cache_peer_access = [],
$via = 'on',
$reply_header_access = [],
$ignore_expect_100 = 'off',
Expand Down Expand Up @@ -70,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 %",
}

}
1 change: 0 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}
14 changes: 2 additions & 12 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
}
27 changes: 15 additions & 12 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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
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
20 changes: 20 additions & 0 deletions templates/squid.conf.long.erb
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,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
Expand Down Expand Up @@ -4151,6 +4165,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
Expand Down
21 changes: 21 additions & 0 deletions templates/squid.conf.short.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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| -%>
Expand All @@ -62,6 +69,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 %>
Expand Down