Skip to content

Commit

Permalink
updating style and test harness
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean OMeara committed Dec 20, 2013
1 parent bb6f973 commit 491d8b0
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 85 deletions.
64 changes: 53 additions & 11 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,61 @@
---
driver_plugin: vagrant
driver_plugin: digitalocean
driver_config:
require_chef_omnibus: true
digitalocean_client_id: <%= ENV['DIGITAL_OCEAN_CLIENT_ID'] %>
digitalocean_api_key: <%= ENV['DIGITAL_OCEAN_API_KEY'] %>
aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %>
ssh_key: <%= ENV['AWS_PRIVATE_KEY_PATH'] %>
rackspace_username: <%= ENV['RACKSPACE_USERNAME'] %>
rackspace_api_key: <%= ENV['RACKSPACE_API_KEY'] %>
require_chef_omnibus: latest

platforms:
- name: ubuntu-12.04
driver_config:
run_list:
- recipe[apt::default]
- name: ubuntu-10.04
run_list:
- recipe[apt::default]
- name: centos-6.4
- name: centos-5.9
# - name: centos-5.8
# driver_plugin: digitalocean
# driver_config:
# image_id: 1601
# flavor_id: 63
# region_id: 4
# ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>

- name: centos-6.4
driver_plugin: digitalocean
driver_config:
image_id: 562354
flavor_id: 63
region_id: 4
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>

- name: amazon-2013.09
driver_plugin: ec2
driver_config:
image_id: ami-3be4bc52
username: ec2-user

- name: ubuntu-1004
driver_plugin: digitalocean
driver_config:
image_id: 14097
flavor_id: 63
region_id: 1
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
run_list:
- recipe[apt]

- name: ubuntu-1204
driver_plugin: digitalocean
driver_config:
image_id: 1505447
flavor_id: 63
region_id: 4
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
run_list:
- recipe[apt]

suites:
- name: default
run_list:
- recipe[squid::default]
- recipe[squid::default]
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AlignParameters:
Enabled: false

Encoding:
Enabled: false

LineLength:
Max: 200

HashSyntax:
EnforcedStyle: hash_rockets

MethodLength:
Enabled: false
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: ruby
bundler_args: --without development integration
rvm:
- 1.9.3
- 2.0.0
before_install:
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
before_script:
- bundle exec berks install
script:
- bundle exec foodcritic -f any . --tags ~FC005
# - bundle exec rubocop
- bundle exec rspec --color --format progress
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

gem 'berkshelf', '~> 2.0'
gem 'chefspec', '~> 3.0'
gem 'foodcritic', '~> 3.0'
gem 'rubocop'

group :integration do
gem 'test-kitchen', '~> 1.0'
gem 'kitchen-vagrant', '~> 0.11'
gem 'kitchen-digitalocean'
gem 'kitchen-ec2'
end
95 changes: 47 additions & 48 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,65 @@

default['squid']['port'] = 3128
default['squid']['network'] = nil
default['squid']['timeout'] = "10"
default['squid']['opts'] = ""
default['squid']['timeout'] = '10'
default['squid']['opts'] = ''

default['squid']['package'] = "squid"
default['squid']['version'] = "3.1"
default['squid']['config_dir'] = "/etc/squid"
default['squid']['config_file'] = "/etc/squid/squid.conf"
default['squid']['log_dir'] = "/var/log/squid"
default['squid']['cache_dir'] = "/var/spool/squid"
default['squid']['coredump_dir'] = "/var/spool/squid"
default['squid']['service_name'] = "squid"
default['squid']['package'] = 'squid'
default['squid']['version'] = '3.1'
default['squid']['config_dir'] = '/etc/squid'
default['squid']['config_file'] = '/etc/squid/squid.conf'
default['squid']['log_dir'] = '/var/log/squid'
default['squid']['cache_dir'] = '/var/spool/squid'
default['squid']['coredump_dir'] = '/var/spool/squid'
default['squid']['service_name'] = 'squid'

default['squid']['listen_interface'] = "eth0"
default['squid']['cache_mem'] = "2048"
default['squid']['cache_size'] = "100"
default['squid']['listen_interface'] = 'eth0'
default['squid']['cache_mem'] = '2048'
default['squid']['cache_size'] = '100'

case platform_family

when "debian"
when 'debian'
case platform
when "debian"
if node['platform_version'] == "6.0.3" then
set['squid']['package'] = "squid3"
set['squid']['version'] = "3.1"
set['squid']['config_dir'] = "/etc/squid3"
set['squid']['config_file'] = "/etc/squid3/squid.conf"
set['squid']['service_name'] = "squid3"
when 'debian'
if node['platform_version'] == '6.0.3'
set['squid']['package'] = 'squid3'
set['squid']['version'] = '3.1'
set['squid']['config_dir'] = '/etc/squid3'
set['squid']['config_file'] = '/etc/squid3/squid.conf'
set['squid']['service_name'] = 'squid3'
end

when "ubuntu"
if node['platform_version'] == "10.04" then
set['squid']['package'] = "squid"
set['squid']['version'] = "2.7"
set['squid']['config_dir'] = "/etc/squid"
set['squid']['config_file'] = "/etc/squid/squid.conf"
set['squid']['service_name'] = "squid"
when 'ubuntu'
if node['platform_version'] == '10.04'
set['squid']['package'] = 'squid'
set['squid']['version'] = '2.7'
set['squid']['config_dir'] = '/etc/squid'
set['squid']['config_file'] = '/etc/squid/squid.conf'
set['squid']['service_name'] = 'squid'

elsif node['platform_version'] == "12.04" then
set['squid']['package'] = "squid3"
set['squid']['version'] = "3.1"
set['squid']['config_dir'] = "/etc/squid3"
set['squid']['config_file'] = "/etc/squid3/squid.conf"
set['squid']['log_dir'] = "/var/log/squid3"
set['squid']['cache_dir'] = "/var/spool/squid3"
set['squid']['coredump_dir'] = "/var/spool/squid3"
set['squid']['service_name'] = "squid3"
elsif node['platform_version'] == '12.04'
set['squid']['package'] = 'squid3'
set['squid']['version'] = '3.1'
set['squid']['config_dir'] = '/etc/squid3'
set['squid']['config_file'] = '/etc/squid3/squid.conf'
set['squid']['log_dir'] = '/var/log/squid3'
set['squid']['cache_dir'] = '/var/spool/squid3'
set['squid']['coredump_dir'] = '/var/spool/squid3'
set['squid']['service_name'] = 'squid3'
end
end

when "rhel"
set['squid']['package'] = "squid"
when 'rhel'
set['squid']['package'] = 'squid'
rhel_version = node['platform_version'].to_f
if rhel_version >= 6 && rhel_version < 7 then set['squid']['version'] = "3.1" end
if rhel_version >= 5 && rhel_version < 6 then set['squid']['version'] = "2.6" end
set['squid']['version'] = '3.1' if rhel_version >= 6 && rhel_version < 7
set['squid']['version'] = '2.6' if rhel_version >= 5 && rhel_version < 6

when "smartos"
set['squid']['package'] = "squid"
set['squid']['version'] = "3.1"
set['squid']['config_dir'] = "/etc/squid"
set['squid']['service_name'] = "squid"
set['squid']['listen_interface'] = "net0"
when 'smartos'
set['squid']['package'] = 'squid'
set['squid']['version'] = '3.1'
set['squid']['config_dir'] = '/etc/squid'
set['squid']['service_name'] = 'squid'
set['squid']['listen_interface'] = 'net0'
end

20 changes: 10 additions & 10 deletions libraries/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
def squid_load_host_acl
host_acl = []
begin
data_bag("squid_hosts").each do |bag|
group = data_bag_item("squid_hosts",bag)
data_bag('squid_hosts').each do |bag|
group = data_bag_item('squid_hosts', bag)
group['net'].each do |host|
host_acl.push [group['id'],group['type'],host]
host_acl.push [group['id'], group['type'], host]
end
end
rescue
Chef::Log.info "no 'squid_hosts' data bag"
Chef::Log.info "no 'squid_hosts' data bag"
end
host_acl
end

def squid_load_url_acl
url_acl = []
begin
data_bag("squid_urls").each do |bag|
group = data_bag_item("squid_urls",bag)
data_bag('squid_urls').each do |bag|
group = data_bag_item('squid_urls', bag)
group['urls'].each do |url|
url_acl.push [group['id'],url]
url_acl.push [group['id'], url]
end
end
rescue
Expand All @@ -32,10 +32,10 @@ def squid_load_url_acl
def squid_load_acls
acls = []
begin
data_bag("squid_acls").each do |bag|
group = data_bag_item("squid_acls",bag)
data_bag('squid_acls').each do |bag|
group = data_bag_item('squid_acls', bag)
group['acl'].each do |acl|
acls.push [acl[1],group['id'],acl[0]]
acls.push [acl[1], group['id'], acl[0]]
end
end
rescue
Expand Down
12 changes: 6 additions & 6 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name "squid"
maintainer "Opscode, Inc."
maintainer_email "[email protected]"
license "Apache 2.0"
description "Installs/Configures squid as a simple caching proxy"
name 'squid'
maintainer 'Opscode, Inc.'
maintainer_email '[email protected]'
license 'Apache 2.0'
description 'Installs/Configures squid as a simple caching proxy'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.2.9"
version '0.2.9'

%w{ debian ubuntu centos fedora redhat scientific suse amazon}.each do |os|
supports os
Expand Down
19 changes: 9 additions & 10 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,24 @@
package node['squid']['package']

# rhel_family sysconfig
if platform_family?("rhel")
template "/etc/sysconfig/squid" do
source "redhat/sysconfig/squid.erb"
notifies :restart, "service[#{node['squid']['service_name']}]", :delayed
mode 00644
end
template '/etc/sysconfig/squid' do
source 'redhat/sysconfig/squid.erb'
notifies :restart, "service[#{node['squid']['service_name']}]", :delayed
mode 00644
only_if { platform_family? 'rhel' }
end

# squid config dir
directory node['squid']['config_dir'] do
action :create
recursive true
owner "root"
owner 'root'
mode 00755
end

# squid mime config
cookbook_file "#{node['squid']['config_dir']}/mime.conf" do
source "mime.conf"
source 'mime.conf'
mode 00644
end

Expand All @@ -72,7 +71,7 @@

# squid config
template node['squid']['config_file'] do
source "squid.conf.erb"
source 'squid.conf.erb'
notifies :reload, "service[#{node['squid']['service_name']}]"
mode 00644
variables(
Expand All @@ -86,5 +85,5 @@
service node['squid']['service_name'] do
supports :restart => true, :status => true, :reload => true
provider Chef::Provider::Service::Upstart if platform?('ubuntu')
action [ :enable, :start ]
action [:enable, :start]
end

0 comments on commit 491d8b0

Please sign in to comment.