Merge branch 'develop' of Linux-Help/cookbook-apt-zabbix into master

This commit is contained in:
Eric Renfro 2016-12-24 20:37:49 +00:00 committed by Gogs
commit e975242f5d
14 changed files with 250 additions and 15 deletions

19
.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
.DS_Store
.vagrant
Berksfile.lock
Gemfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
# Bundler
bin/*
.bundle/*
# Test-Kitchen
.kitchen/
.kitchen.local.yml

26
.kitchen.yml Normal file
View File

@ -0,0 +1,26 @@
---
driver:
name: vagrant
provisioner:
name: chef_zero
nodes_path: test/fixtures/nodes
clients_path: test/fixtures/clients
environments_path: test/fixtures/environments
data_bags_path: test/fixtures/data_bags
chef_client_path: /usr/bin/chef-client
client_rb:
environment: test
platforms:
- name: debian-8.6
driver_config:
vm_hostname: integration.deb.test
require_chef_omnibus: false
suites:
- name: default
run_list:
- recipe[apt-zabbix::default]
attributes:

2
.rspec Normal file
View File

@ -0,0 +1,2 @@
--color
--require spec_helper

View File

@ -1,14 +0,0 @@
DEPENDENCIES
yum (~> 3.10.0)
yum-epel (~> 0.6.6)
yum-zabbix
path: .
metadata: true
GRAPH
yum (3.10.0)
yum-epel (0.6.6)
yum (~> 3.10.0)
yum-zabbix (0.1.0)
yum (>= 3.2.0)
yum-epel (>= 0.0.0)

20
Gemfile Normal file
View File

@ -0,0 +1,20 @@
source 'https://rubygems.org'
gem 'berkshelf'
# Uncomment these lines if you want to live on the Edge:
#
# group :development do
# gem "berkshelf", github: "berkshelf/berkshelf"
# gem "vagrant", github: "mitchellh/vagrant", tag: "v1.6.3"
# end
#
# group :plugins do
# gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf"
# gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus"
# end
gem "test-kitchen"
gem "kitchen-vagrant"
gem "hitimes"
gem "ffi"

1
chefignore Normal file
View File

@ -0,0 +1 @@
.kitchen

View File

@ -4,7 +4,7 @@ maintainer_email 'psi-jack@linux-help.org'
license 'Apache 2.0'
description 'Installs and configures the NUX Community Desktop Yum Repository'
long_description ''
version '0.1.0'
version '0.1.2'
issues_url 'http://gogs.home.ld/Linux-Help/cookbook-apt-zabbix/issues'
source_url 'http://gogs.home.ld/Linux-Help/cookbook-apt-zabbix'

10
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,10 @@
require 'chefspec'
require 'chefspec/berkshelf'
RSpec.configure do |config|
config.color = true
config.log_level = :error
end
ChefSpec::Coverage.start!

View File

@ -0,0 +1,45 @@
require 'spec_helper'
describe 'apt-zabbix::default' do
#context 'Creates Zabbix APT repository' do
# let(:chef_run) do
# ChefSpec::SoloRunner.new do |node|
# # Create a new environment (you could also use a different :let block or :before block)
# env = Chef::Environment.new
# env.name 'unit_test'
#
# # Stub the node to return this environment
# allow(node).to receive(:chef_environment).and_return(env.name)
#
# # Stub any calls to Environment.load to return this environment
# allow(Chef::Environment).to receive(:load).and_return(env)
#
# # Stubbing out fqdn node attribute
# node.automatic['fqdn'] = 'unit.testing.stub'
# end.converge(described_recipe)
# end
virtual_box_version = '5.0'
let(:runner) { ChefSpec::ServerRunner.new(platform: 'debian', version: '8.6') }
let(:chef_run) { runner.converge('apt-zabbix::default') }
#let(:chef_run) do
# ChefSpec::SoloRunner.new do |node|
# node.set['virtualbox']['version'] = virtual_box_version
# end.converge(described_recipe)
#end
#before do
# allow(::File).to receive(:executable?).and_return(true)
#end
it 'installs the apt repository' do
expect(chef_run).to add_apt_repository('zabbix').with(
:uri => 'http://repo.zabbix.com/zabbix/3.0/debian',
:key => 'zabbix-official-repo.key',
:distribution => 'jessie',
:components => ['main']
)
#expect(chef_run).to render_file('/etc/apt/sources.list.d/zabbix.list').with_content('deb "http://repo.zabbix.com/zabbix/3.0/debian" jessie main')
end
end

66
test/Vagrantfile.erb Normal file
View File

@ -0,0 +1,66 @@
Vagrant.configure("2") do |c|
c.vm.box = "<%= config[:box] %>"
c.vm.box_url = "<%= config[:box_url] %>"
if Vagrant.has_plugin?("vagrant-cachier")
c.cache.auto_detect = true
c.cache.scope = :box
end
#if Vagrant.has_plugin?("vagrant-omnibus")
# c.omnibus.cache_packages = true
# c.omnibus.chef_version = <%= config[:chef_version] %>
#end
if Vagrant.has_plugin?("vagrant-libvirt")
c.vm.provider :libvirt do |libvirt|
libvirt.storage_pool_name = "Virt-SSD"
libvirt.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
end
end
c.vbguest.auto_update = false
<% if config[:vm_hostname] %>
c.vm.hostname = "<%= config[:vm_hostname] %>"
<% end %>
<% if config[:guest] %>
c.vm.guest = <%= config[:guest] %>
<% end %>
<% if config[:username] %>
c.ssh.username = "<%= config[:username] %>"
<% end %>
<% if config[:ssh_key] %>
c.ssh.private_key_path = "<%= config[:ssh_key] %>"
<% end %>
<% Array(config[:network]).each do |opts| %>
c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>)
<% end %>
c.vm.synced_folder ".", "/vagrant", disabled: true
<% config[:synced_folders].each do |source, destination, options| %>
c.vm.synced_folder "<%= source %>", "<%= destination %>", <%= options %>
<% end %>
c.vm.provider :<%= config[:provider] %> do |p|
<% config[:customize].each do |key, value| %>
<% case config[:provider]
when "virtualbox" %>
p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"]
<% when "rackspace", "softlayer" %>
p.<%= key %> = "<%= value%>"
<% when /^vmware_/ %>
<% if key == :memory %>
<% unless config[:customize].include?(:memsize) %>
p.vmx["memsize"] = "<%= value %>"
<% end %>
<% else %>
p.vmx["<%= key %>"] = "<%= value %>"
<% end %>
<% end %>
<% end %>
end
end

View File

@ -0,0 +1,16 @@
{
"name": "integration_test_env",
"description": "placeholder for integration testing",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
}
}

17
test/fixtures/environments/test.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"id": "test",
"name": "test",
"description": "placeholder for integration testing",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
}
}

View File

@ -0,0 +1,23 @@
require 'spec_helper'
describe 'apt-zabbix::default' do
### REPOSITORIES
#
describe 'Repositories should be installed:' do
describe file('/etc/apt/sources.list.d') do
it { should be_directory }
it { should be_mode 755 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end
describe file('/etc/apt/sources.list.d/zabbix.list') do
it { should exist }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match('deb "http://repo.zabbix.com/zabbix/3.0/debian" jessie main') }
end
end
end

View File

@ -0,0 +1,4 @@
require 'serverspec'
set :backend, :exec