Skip to content
Snippets Groups Projects
Commit 410b29a6 authored by Mathieu Sauve-Frankel's avatar Mathieu Sauve-Frankel
Browse files

fix instructions for usage with chef_handler and add integration tests

parent ba497385
No related branches found
No related tags found
No related merge requests found
*.gem *.gem
.kitchen/
.kitchen.local.yml
---
driver:
name: vagrant
pre_create_command: 'rake clean && rake build'
synced_folders: [
[ '/tmp/chef-handler-mail-build', '/tmp/build' ]
]
provisioner:
name: chef_solo
platforms:
- name: ubuntu-12.04
run_list: recipe[apt]
suites:
- name: default
run_list:
- recipe[chef-handler-mail-test]
- recipe[postfix]
attributes:
site :opscode
cookbook 'apt'
cookbook 'chef_handler'
cookbook 'postfix'
cookbook 'chef-handler-mail-test', path: 'test/cookbooks/chef-handler-mail-test'
{
"sources": {
"apt": {
"locked_version": "2.3.4"
},
"chef_handler": {
"locked_version": "1.1.4"
},
"postfix": {
"locked_version": "3.0.4"
},
"chef-handler-mail-test": {
"path": "./test/cookbooks/chef-handler-mail-test"
}
}
}
...@@ -18,10 +18,10 @@ Using /etc/chef/config.rb ...@@ -18,10 +18,10 @@ Using /etc/chef/config.rb
Using chef_handler LWRP Using chef_handler LWRP
chef_gem "chef-handler-mail" chef_gem 'chef-handler-mail'
gem "chef-handler-mail" require 'chef/handler/mail'
chef_handler "MailHandler" do chef_handler 'MailHandler' do
source 'chef/handler/mail' source 'chef/handler/mail'
arguments :to_address => "root" arguments :to_address => "root"
action :nothing action :nothing
......
...@@ -7,6 +7,8 @@ GEM_VERSION = MailHandler::VERSION ...@@ -7,6 +7,8 @@ GEM_VERSION = MailHandler::VERSION
desc "Build #{GEM_NAME} gem" desc "Build #{GEM_NAME} gem"
task :build do task :build do
system "gem build #{GEM_NAME}.gemspec" system "gem build #{GEM_NAME}.gemspec"
system "mkdir -p /tmp/chef-handler-mail-build"
system "cp #{GEM_NAME}-#{GEM_VERSION}.gem /tmp/chef-handler-mail-build/#{GEM_NAME}.gem"
end end
desc "Push #{GEM_NAME} to rubygems.org" desc "Push #{GEM_NAME} to rubygems.org"
...@@ -16,5 +18,13 @@ end ...@@ -16,5 +18,13 @@ end
desc "Clean up build gems" desc "Clean up build gems"
task :clean do task :clean do
system "rm #{GEM_NAME}-#{GEM_VERSION}.gem" system "rm -f #{GEM_NAME}-#{GEM_VERSION}.gem"
system "rm -f test/build/#{GEM_NAME}.gem"
end
begin
require 'kitchen/rake_tasks'
Kitchen::RakeTasks.new
rescue LoadError
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
end end
chef-handler-mail-test Cookbook
===============================
This cookbook provides a working example of how to use Opscode's
chef\_handler cookbook to install and enable the chef-mail-handler
gem
It is intended for integration testing of the chef-mail-handler gem
using test-kitchen
name 'chef-handler-mail-test'
maintainer 'Mathieu Sauve-Frankel'
maintainer_email 'msf@kisoku.net'
license 'Apache 2.0'
description 'Installs/Configures chef-handler-mail-test'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'chef_handler'
#
# Cookbook Name:: chef-handler-mail-test
# Recipe:: default
#
# Copyright:: 2014, Mathieu Sauve-Frankel <msf@kisoku.net>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
chef_gem 'chef-handler-mail' do
source '/tmp/build/chef-handler-mail.gem'
end
require 'chef/handler/mail'
chef_handler 'MailHandler' do
source 'chef/handler/mail'
arguments :to_address => "root"
action :nothing
end.run_action(:enable)
package 'mailutils'
require 'serverspec'
include Serverspec::Helper::Exec
include Serverspec::Helper::DetectOS
describe file('/var/mail/root') do
its(:content) {
should match "Subject: Successful Chef run on node default-ubuntu-1204.vagrantup.com"
}
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment