From 352b378843b5545664bf9e6f41f33ae92996ca7d Mon Sep 17 00:00:00 2001 From: Corey Osman Date: Fri, 4 Sep 2015 10:40:05 -0700 Subject: [PATCH 1/3] ran retrospec to generate module tests --- .fixtures.yml | 8 + .gitignore | 11 ++ .puppet-lint.rc | 8 + .travis.yml | 14 ++ Gemfile | 27 +++ Gemfile.lock | 406 ++++++++++++++++++++++++++++++++++++++++ Rakefile | 72 +++++++ Vagrantfile | 95 ++++++++++ spec/shared_contexts.rb | 43 +++++ spec/spec_helper.rb | 11 ++ 10 files changed, 695 insertions(+) create mode 100644 .fixtures.yml create mode 100644 .gitignore create mode 100644 .puppet-lint.rc create mode 100644 .travis.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100644 Vagrantfile create mode 100644 spec/shared_contexts.rb create mode 100644 spec/spec_helper.rb diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..1d1aab2 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,8 @@ +fixtures: + symlinks: + puppet-assert: "#{source_dir}" + repositories: + stdlib: + repo: https://github.com/puppetlabs/puppetlabs-stdlib.git + ref: 4.6.0 + forge_modules: diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..daa0751 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.*.sw? +pkg +spec/fixtures +.rspec_system +.vagrant +.bundle +vendor +.idea +.project +.DS_Store + diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..a37b48e --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,8 @@ +# Use this file to instruct puppet-lint to ignore certain checks. +# For the complete list of checks and flags to disable them, +# refer to . + +# Examples (uncomment before use): +#--no-80chars-check +#--no-class_inherits_from_params_class-check +#--no-inherits_across_namespaces-check diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4c44646 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +branches: +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +bundler_args: --without development + +rvm: +- 1.9.3 +- 2.0.0 +- 2.1.5 +- 2.2.0 +env: + matrix: + - PUPPET_GEM_VERSION="~> 3.2" + - PUPPET_GEM_VERSION="~> 3.7" + diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..dd95eb4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,27 @@ +source "https://rubygems.org" + +group :test do + gem "rake" + gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.3' + gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git' + gem "puppetlabs_spec_helper" + gem 'rspec-puppet-utils', :git => 'https://github.com/Accuity/rspec-puppet-utils.git' + gem 'hiera-puppet-helper', :git => 'https://github.com/bobtfish/hiera-puppet-helper.git' + gem "metadata-json-lint" + gem 'puppet-syntax' + gem 'puppet-lint' +end + +group :integration do + gem "beaker", :git => 'https://github.com/puppetlabs/beaker.git' + gem "beaker-rspec", :git => 'https://github.com/puppetlabs/beaker-rspec.git' + gem "vagrant-wrapper" + gem 'serverspec' +end + +group :development do + gem "travis" + gem "travis-lint" + gem "puppet-blacksmith" + gem "guard-rake" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..276fd22 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,406 @@ +GIT + remote: https://github.com/Accuity/rspec-puppet-utils.git + revision: 14dfb7ed20541033023b50d39d9a9d9fdb576c9b + specs: + rspec-puppet-utils (2.1.0) + +GIT + remote: https://github.com/bobtfish/hiera-puppet-helper.git + revision: 155f132c0b225db4ff64db49f17d6c5bf354b871 + specs: + hiera-puppet-helper (2.0.1) + +GIT + remote: https://github.com/puppetlabs/beaker-rspec.git + revision: 69980e14d49df7e8763b08482bebe1483d4d3bf6 + specs: + beaker-rspec (5.2.2) + beaker (~> 2.0) + rspec + serverspec (~> 2) + specinfra (~> 2) + +GIT + remote: https://github.com/puppetlabs/beaker.git + revision: d16fef006ec8bd67c230d1a207b8d9eb83c28885 + specs: + beaker (2.22.0) + aws-sdk (~> 1.57) + beaker-answers (~> 0.0) + docker-api + fission (~> 0.4) + fog (~> 1.25) + google-api-client (~> 0.8) + hocon (~> 0.1) + inifile (~> 2.0) + json (~> 1.8) + minitest (~> 5.4) + net-scp (~> 1.2) + net-ssh (~> 2.9) + open_uri_redirections (~> 0.2.1) + rbvmomi (~> 1.8) + rsync (~> 1.0.9) + stringify-hash (~> 0.0) + unf (~> 0.1) + +GIT + remote: https://github.com/rodjek/rspec-puppet.git + revision: bd8e54e3ae144b57bfd9efca7a8d92a116fa406b + specs: + rspec-puppet (2.2.1.pre) + rspec + +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.1) + activesupport (4.2.4) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.3.8) + autoparse (0.3.3) + addressable (>= 2.3.1) + extlib (>= 0.9.15) + multi_json (>= 1.0.0) + aws-sdk (1.65.0) + aws-sdk-v1 (= 1.65.0) + aws-sdk-v1 (1.65.0) + json (~> 1.4) + nokogiri (>= 1.4.4) + backports (3.6.6) + beaker-answers (0.2.2) + require_all (~> 1.3.2) + stringify-hash (~> 0.0.0) + builder (3.2.2) + coderay (1.1.0) + diff-lcs (1.2.5) + docker-api (1.22.4) + excon (>= 0.38.0) + json + domain_name (0.5.24) + unf (>= 0.0.5, < 1.0.0) + ethon (0.7.4) + ffi (>= 1.3.0) + excon (0.45.4) + extlib (0.9.16) + facter (1.7.6) + faraday (0.9.1) + multipart-post (>= 1.2, < 3) + faraday_middleware (0.10.0) + faraday (>= 0.7.4, < 0.10) + ffi (1.9.10) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.34.0) + fog-atmos + fog-aws (>= 0.6.0) + fog-brightbox (~> 0.4) + fog-core (~> 1.32) + fog-dynect (~> 0.0.2) + fog-ecloud (~> 0.1) + fog-google (>= 0.0.2) + fog-json + fog-local + fog-powerdns (>= 0.1.1) + fog-profitbricks + fog-radosgw (>= 0.0.2) + fog-riakcs + fog-sakuracloud (>= 0.0.4) + fog-serverlove + fog-softlayer + fog-storm_on_demand + fog-terremark + fog-vmfusion + fog-voxel + fog-xml (~> 0.1.1) + ipaddress (~> 0.5) + nokogiri (~> 1.5, >= 1.5.11) + fog-atmos (0.1.0) + fog-core + fog-xml + fog-aws (0.7.6) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-brightbox (0.9.0) + fog-core (~> 1.22) + fog-json + inflecto (~> 0.0.2) + fog-core (1.32.1) + builder + excon (~> 0.45) + formatador (~> 0.2) + mime-types + net-scp (~> 1.1) + net-ssh (>= 2.1.3) + fog-dynect (0.0.2) + fog-core + fog-json + fog-xml + fog-ecloud (0.3.0) + fog-core + fog-xml + fog-google (0.0.7) + fog-core + fog-json + fog-xml + fog-json (1.0.2) + fog-core (~> 1.0) + multi_json (~> 1.10) + fog-local (0.2.1) + fog-core (~> 1.27) + fog-powerdns (0.1.1) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + fog-profitbricks (0.0.5) + fog-core + fog-xml + nokogiri + fog-radosgw (0.0.4) + fog-core (>= 1.21.0) + fog-json + fog-xml (>= 0.0.1) + fog-riakcs (0.1.0) + fog-core + fog-json + fog-xml + fog-sakuracloud (1.0.1) + fog-core + fog-json + fog-serverlove (0.1.2) + fog-core + fog-json + fog-softlayer (0.4.7) + fog-core + fog-json + fog-storm_on_demand (0.1.1) + fog-core + fog-json + fog-terremark (0.1.0) + fog-core + fog-xml + fog-vmfusion (0.1.0) + fission + fog-core + fog-voxel (0.1.0) + fog-core + fog-xml + fog-xml (0.1.2) + fog-core + nokogiri (~> 1.5, >= 1.5.11) + formatador (0.2.5) + gh (0.14.0) + addressable + backports + faraday (~> 0.8) + multi_json (~> 1.0) + net-http-persistent (>= 2.7) + net-http-pipeline + google-api-client (0.8.6) + activesupport (>= 3.2) + addressable (~> 2.3) + autoparse (~> 0.3) + extlib (~> 0.9) + faraday (~> 0.9) + googleauth (~> 0.3) + launchy (~> 2.4) + multi_json (~> 1.10) + retriable (~> 1.4) + signet (~> 0.6) + googleauth (0.4.2) + faraday (~> 0.9) + jwt (~> 1.4) + logging (~> 2.0) + memoist (~> 0.12) + multi_json (~> 1.11) + signet (~> 0.6) + guard (2.13.0) + formatador (>= 0.2.4) + listen (>= 2.7, <= 4.0) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-rake (1.0.0) + guard + rake + hiera (1.3.4) + json_pure + highline (1.7.3) + hocon (0.9.3) + http-cookie (1.0.2) + domain_name (~> 0.5) + i18n (0.7.0) + inflecto (0.0.2) + inifile (2.0.2) + ipaddress (0.8.0) + json (1.8.3) + json_pure (1.8.2) + jwt (1.5.1) + launchy (2.4.3) + addressable (~> 2.3) + listen (3.0.3) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + little-plugger (1.1.4) + logging (2.0.0) + little-plugger (~> 1.1) + multi_json (~> 1.10) + lumberjack (1.0.9) + memoist (0.12.0) + metaclass (0.0.4) + metadata-json-lint (0.0.6) + json + spdx-licenses (~> 1.0) + method_source (0.8.2) + mime-types (2.6.1) + mini_portile (0.6.2) + minitest (5.8.0) + mocha (1.1.0) + metaclass (~> 0.0.1) + multi_json (1.11.2) + multipart-post (2.0.0) + nenv (0.2.0) + net-http-persistent (2.9.4) + net-http-pipeline (1.0.1) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.2) + net-telnet (0.1.1) + netrc (0.10.3) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + notiffany (0.0.7) + nenv (~> 0.1) + shellany (~> 0.0) + open_uri_redirections (0.2.1) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + puppet (3.7.5) + facter (> 1.6, < 3) + hiera (~> 1.0) + json_pure + puppet-blacksmith (3.3.1) + puppet (>= 2.7.16) + rest-client + puppet-lint (1.1.0) + puppet-syntax (2.0.0) + rake + puppetlabs_spec_helper (0.10.3) + mocha + puppet-lint + puppet-syntax + rake + rspec-puppet + pusher-client (0.6.2) + json + websocket (~> 1.0) + rake (10.4.2) + rb-fsevent (0.9.6) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + rbvmomi (1.8.2) + builder + nokogiri (>= 1.4.1) + trollop + require_all (1.3.2) + rest-client (1.8.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) + retriable (1.4.1) + rspec (3.3.0) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-core (3.3.2) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-its (1.2.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.3.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-support (3.3.0) + rsync (1.0.9) + serverspec (2.23.0) + multi_json + rspec (~> 3.0) + rspec-its + specinfra (~> 2.43) + sfl (2.2) + shellany (0.0.1) + signet (0.6.1) + addressable (~> 2.3) + extlib (~> 0.9) + faraday (~> 0.9) + jwt (~> 1.5) + multi_json (~> 1.10) + slop (3.6.0) + spdx-licenses (1.0.0) + json + specinfra (2.43.1) + net-scp + net-ssh (~> 2.7) + net-telnet + sfl + stringify-hash (0.0.2) + thor (0.19.1) + thread_safe (0.3.5) + travis (1.8.0) + addressable (~> 2.3) + backports + faraday (~> 0.9) + faraday_middleware (~> 0.9, >= 0.9.1) + gh (~> 0.13) + highline (~> 1.6) + launchy (~> 2.1) + pry (~> 0.9, < 0.10) + pusher-client (~> 0.4) + typhoeus (~> 0.6, >= 0.6.8) + travis-lint (2.0.0) + json + trollop (2.1.2) + typhoeus (0.7.3) + ethon (>= 0.7.4) + tzinfo (1.2.2) + thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) + vagrant-wrapper (2.0.3) + websocket (1.2.2) + +PLATFORMS + ruby + +DEPENDENCIES + beaker! + beaker-rspec! + guard-rake + hiera-puppet-helper! + metadata-json-lint + puppet (~> 3.7.3) + puppet-blacksmith + puppet-lint + puppet-syntax + puppetlabs_spec_helper + rake + rspec-puppet! + rspec-puppet-utils! + serverspec + travis + travis-lint + vagrant-wrapper diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..cb628a0 --- /dev/null +++ b/Rakefile @@ -0,0 +1,72 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' + +# These two gems aren't always present, for instance +# on Travis with --without development +begin + require 'puppet_blacksmith/rake_tasks' + Blacksmith::RakeTask.new do |t| + t.tag_pattern = "v%s" # Use a custom pattern with git tag. %s is replaced with the version number. + end +rescue LoadError +end + +PuppetLint.configuration.relative = true +PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" +PuppetLint.configuration.fail_on_warnings = true + +# Forsake support for Puppet 2.6.2 for the benefit of cleaner code. +# http://puppet-lint.com/checks/class_parameter_defaults/ +PuppetLint.configuration.send('disable_class_parameter_defaults') +# http://puppet-lint.com/checks/class_inherits_from_params_class/ +PuppetLint.configuration.send('disable_class_inherits_from_params_class') + +exclude_paths = [ + "pkg/**/*", + "vendor/**/*", + "spec/**/*", +] +PuppetLint.configuration.ignore_paths = exclude_paths +PuppetSyntax.exclude_paths = exclude_paths + +task :metadata do + sh "metadata-json-lint metadata.json" +end + +desc "Run syntax, lint, and spec tests." +task :test => [ + :syntax, + :lint, + :spec, + :metadata, + ] +def io_popen(command) + IO.popen(command) do |io| + io.each do |line| + print line + yield line if block_given? + end + end +end + +desc 'Vagrant VM power up and provision' +task :vagrant_up, [:manifest, :hostname] do |t, args| + args.with_defaults(:manifest => 'init.pp', :hostname => '') + Rake::Task['spec_prep'].execute + ENV['VAGRANT_MANIFEST'] = args[:manifest] + provision = false + io_popen("vagrant up #{args[:hostname]}") do |line| + provision = true if line =~ /is already running./ + end + io_popen("vagrant provision #{args[:hostname]}") if provision +end + +# Cleanup vagrant environment +desc 'Vagrant VM shutdown and fixtures cleanup' +task :vagrant_destroy do + Rake::Task['spec_prep'].execute + `vagrant destroy -f` + Rake::Task['spec_clean'].execute +end diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..573b903 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,95 @@ +def vm(opt) + module_name = opt.fetch(:module).to_s || raise(ArgumentError, 'Must provide puppet module name') + hostname = opt.fetch(:hostname, module_name).to_s + memory = opt.fetch(:memory, 512) + cpu = opt.fetch(:cpu, 1) + box = opt.fetch(:box).to_s || raise(ArgumentError, 'Must provide box type.') + url = opt.fetch(:url, '').to_s + os_type = opt[:os_type] || opt[:type] || :linux + gui = opt.fetch(:gui, false) + ports = Array(opt.fetch(:port, [])) + iso = opt.fetch(:iso, nil) + proj_root = File.expand_path(File.join(File.dirname(__FILE__))) + fixture_modules = File.join(proj_root, 'spec', 'fixtures', 'modules') + + Vagrant.configure('2') do |conf| + + # forward all the ports + ports.each do |p| + conf.vm.network(:forwarded_port, guest: p, host: p, auto_correct: true) + end + + if os_type == :windows + conf.ssh.username = 'vagrant' + conf.winrm.username = 'vagrant' + conf.winrm.password = 'vagrant' + end + + conf.vm.define hostname.to_sym do |mod| + mod.vm.box = box + mod.vm.box_url = url + + if os_type == :windows + mod.vm.guest = :windows + mod.vm.communicator = 'winrm' + mod.vm.synced_folder './' , "/ProgramData/PuppetLabs/puppet/etc/modules/#{module_name}" + mod.vm.synced_folder 'spec/fixtures/modules' , '/temp/modules' + else + mod.vm.synced_folder './', "/etc/puppet/modules/#{module_name}" + mod.vm.synced_folder 'spec/fixtures/modules', '/tmp/puppet/modules' + end + + mod.vm.hostname = hostname + + mod.vm.provider :vmware_fusion do |f| + f.gui = gui + f.vmx['displayName'] = hostname + f.vmx['memsize'] = memory + f.vmx['numvcpus'] = cpu + if iso + f.vmx['ide1:0.devicetype'] = "cdrom-image" + f.vmx['ide1:0.filename'] = iso + end + end + + mod.vm.provider :vmware_workstation do |f| + f.gui = gui + f.vmx['displayName'] = hostname + f.vmx['memsize'] = memory + f.vmx['numvcpus'] = cpu + if iso + f.vmx['ide1:0.devicetype'] = "cdrom-image" + f.vmx['ide1:0.filename'] = iso + end + end + + mod.vm.provider :virtualbox do |v| + v.gui = gui + v.name = hostname + v.memory = memory + v.cpus = cpu + end + + if os_type == :windows + manifest = ENV['VAGRANT_MANIFEST'] || 'init.pp' + #mod.vm.provision :shell, :inline => "@powershell -NoProfile -ExecutionPolicy Bypass -Command \"iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))\" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" + #mod.vm.provision :shell, :inline => "choco install puppet" + mod.vm.provision :shell, :inline => "puppet apply --modulepath 'C:/ProgramData/PuppetLabs/puppet/etc/modules;C:/temp/modules' --verbose C:/ProgramData/PuppetLabs/puppet/etc/modules/#{module_name}/tests/#{manifest}" + else + mod.vm.provision :puppet do |p| + p.manifests_path = 'tests' + # p.hiera_config_path = File.join(fixture_modules, 'hieradata', 'hiera.yaml') + p.manifest_file = ENV['VAGRANT_MANIFEST'] || 'init.pp' + #p.module_path = fixture_modules + # because of how symlinks are handled via the spec_helper we are forced to mount the modules is different locations + # otherwise we could just use the above option + p.options = '--modulepath="/etc/puppet/modules:/tmp/puppet/modules"' + end + end + end + end +end +module_name = File.basename(File.expand_path(File.join(File.dirname(__FILE__)))) +vm :hostname => 'win2012r2', :module => module_name, :box => 'opentable/win-2012r2-standard-amd64-nocm', :url => 'opentable/win-2012r2-standard-amd64-nocm', :os_type => :windows, :cpu => 1, :memory => 4096, :gui => true +vm :hostname => 'win2008r2', :module => module_name, :box => 'opentable/win-2008r2-standard-amd64-nocm', :url => 'opentable/win-2008r2-standard-amd64-nocm', :os_type => :windows, :cpu => 1, :memory => 4096, :gui => true +vm :hostname => 'centos6', :module => module_name, :box => 'puppetlabs/centos-6.6-64-puppet', :url => 'puppetlabs/centos-6.6-64-puppet', :cpu => 1, :memory => 2048, :gui => false diff --git a/spec/shared_contexts.rb b/spec/shared_contexts.rb new file mode 100644 index 0000000..e2e7e42 --- /dev/null +++ b/spec/shared_contexts.rb @@ -0,0 +1,43 @@ +# optional, this should be the path to where the hiera data config file is in this repo +# You must update this if your actual hiera data lives inside your module. +# I only assume you have a separate repository for hieradata and its include in your .fixtures +hiera_config_file = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures','modules','hieradata', 'hiera.yaml')) + +# hiera_config and hiera_data are mutually exclusive contexts. + +shared_context :global_hiera_data do + let(:hiera_data) do + { + + } + end +end + +shared_context :hiera do + # example only, + let(:hiera_data) do + {:some_key => "some_value" } + end +end + +shared_context :linux_hiera do + # example only, + let(:hiera_data) do + {:some_key => "some_value" } + end +end + +# In case you want a more specific set of mocked hiera data for windows +shared_context :windows_hiera do + # example only, + let(:hiera_data) do + {:some_key => "some_value" } + end +end + +# you cannot use this in addition to any of the hiera_data contexts above +shared_context :real_hiera_data do + let(:hiera_config) do + hiera_config_file + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..d214aff --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,11 @@ +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-utils' +require 'hiera-puppet-helper' + +# Uncomment this to show coverage report, also useful for debugging +#at_exit { RSpec::Puppet::Coverage.report! } + +RSpec.configure do |c| + c.formatter = 'documentation' + c.mock_with :rspec +end From b93f99bbcbdc76b30204454cf757d9706f9db97a Mon Sep 17 00:00:00 2001 From: Corey Osman Date: Fri, 4 Sep 2015 10:59:29 -0700 Subject: [PATCH 2/3] updates the README --- README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ef86495..3d5656d 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,17 @@ You can temporarily disable an assert by setting its ensure parameter to absent. Usage ======= - +```puppet assert { 'This should be applied': - condition => true + condition => true, + message => "Look at me I am in the report now", } -> class { 'two': } assert { 'This should NOT be applied': - condition => false + condition => false, + message => "Look, I made your catalog run turn RED", + } -> class { 'three': } @@ -33,6 +36,20 @@ Usage } -> class { 'four': } +# other use case + +assert{'linux security check': + condition => $::linux_security_check == 'pass', # depends on a custom fact and compares the value + message => 'Linux control 12345 did not pass, do what you gotta do to fix it' +} + +``` + +Assert Type Properties +========== +* condition (currently only accepts true or false) +* message (overrides the title of the resource and supplies a message in the report) +* ensure (present or absent) Contact ======= @@ -46,6 +63,7 @@ Credit ======= The development of this code was sponsored by Coverity. +Additional modifications by Corey Osman License ======= @@ -70,4 +88,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 4b87f07dea7ce0408cf1c43f8e58553c622e0768 Mon Sep 17 00:00:00 2001 From: Corey Osman Date: Fri, 4 Sep 2015 10:59:35 -0700 Subject: [PATCH 3/3] add metadata.json * keeps up with the latest puppet module trends by replacing the Modulefile --- metadata.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 metadata.json diff --git a/metadata.json b/metadata.json new file mode 100755 index 0000000..1adb990 --- /dev/null +++ b/metadata.json @@ -0,0 +1,15 @@ +{ + "author": "Ben Ford ", + "dependencies": [], + "license": "Apache License, Version 2.0", + "name": "binford2k-assert", + "operatingsystem_support": [ + ], + "project_page": "https://github.com/binford2k", + "requirements": [], + "source": "https://github.com/binford2k", + "issues_url": "https://github.com/binford2k/issues", + "summary": "Allows one to specify an assert as a resource that classes or resources depend on. If the assert fails, all dependencies will be skipped.", + "tags": [], + "version": "0.1.0" +}