mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
add kitchen-puppet example module
This commit is contained in:
parent
5a3acfe03e
commit
9e12095bd8
15 changed files with 144 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,3 +6,5 @@ coverage
|
|||
.delivery/cli.toml
|
||||
Berksfile.lock
|
||||
.bundle
|
||||
.librarian
|
||||
Puppetfile.lock
|
||||
|
|
22
examples/kitchen-puppet/.kitchen.yml
Normal file
22
examples/kitchen-puppet/.kitchen.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
driver:
|
||||
name: vagrant
|
||||
|
||||
provisioner:
|
||||
name: puppet_apply
|
||||
# Not installing chef since inspec is used for testing
|
||||
require_chef_for_busser: false
|
||||
manifests_path: manifests
|
||||
|
||||
verifier:
|
||||
name: inspec
|
||||
|
||||
platforms:
|
||||
- name: centos-7.1
|
||||
- name: ubuntu-12.04
|
||||
- name: ubuntu-14.04
|
||||
|
||||
suites:
|
||||
- name: default
|
||||
provisioner:
|
||||
manifest: site.pp
|
23
examples/kitchen-puppet/Gemfile
Normal file
23
examples/kitchen-puppet/Gemfile
Normal file
|
@ -0,0 +1,23 @@
|
|||
# encoding: utf-8
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'inspec', path: '../../.'
|
||||
gem 'r-train', git: 'git@github.com:chef/train.git'
|
||||
|
||||
group :test do
|
||||
gem 'bundler', '~> 1.5'
|
||||
gem 'minitest', '~> 5.5'
|
||||
gem 'rake', '~> 10'
|
||||
gem 'rubocop', '~> 0.33.0'
|
||||
gem 'simplecov', '~> 0.10'
|
||||
end
|
||||
|
||||
group :integration do
|
||||
gem 'berkshelf', '~> 4.0'
|
||||
gem 'test-kitchen', '~> 1.4'
|
||||
gem 'kitchen-vagrant'
|
||||
gem 'kitchen-puppet'
|
||||
gem 'librarian-puppet'
|
||||
gem 'kitchen-inspec', git: 'git@github.com:chef/kitchen-inspec.git'
|
||||
gem 'concurrent-ruby', '~> 0.9'
|
||||
end
|
25
examples/kitchen-puppet/Puppetfile
Normal file
25
examples/kitchen-puppet/Puppetfile
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env ruby
|
||||
#^syntax detection
|
||||
|
||||
forge "https://forgeapi.puppetlabs.com"
|
||||
|
||||
# use dependencies defined in metadata.json
|
||||
metadata
|
||||
|
||||
# use dependencies defined in Modulefile
|
||||
# modulefile
|
||||
|
||||
# A module from the Puppet Forge
|
||||
# mod 'puppetlabs-stdlib'
|
||||
|
||||
# A module from git
|
||||
# mod 'puppetlabs-ntp',
|
||||
# :git => 'git://github.com/puppetlabs/puppetlabs-ntp.git'
|
||||
|
||||
# A module from a git branch/tag
|
||||
# mod 'puppetlabs-apt',
|
||||
# :git => 'https://github.com/puppetlabs/puppetlabs-apt.git',
|
||||
# :ref => '1.4.x'
|
||||
|
||||
# A module from Github pre-packaged tarball
|
||||
# mod 'puppetlabs-apache', '0.6.0', :github_tarball => 'puppetlabs/puppetlabs-apache'
|
33
examples/kitchen-puppet/manifests/site.pp
Normal file
33
examples/kitchen-puppet/manifests/site.pp
Normal file
|
@ -0,0 +1,33 @@
|
|||
# == Class prepare::site
|
||||
#
|
||||
|
||||
# Install nginx from package repos
|
||||
case $osfamily {
|
||||
'RedHat': {
|
||||
yumrepo { 'nginx':
|
||||
descr => 'Nginx Repo',
|
||||
baseurl => 'http://nginx.org/packages/centos/7/x86_64',
|
||||
gpgkey => 'http://nginx.org/keys/nginx_signing.key',
|
||||
enabled => 1
|
||||
}
|
||||
|
||||
package { 'nginx':
|
||||
require => [Yumrepo[nginx]],
|
||||
ensure => 'latest'
|
||||
}
|
||||
}
|
||||
'Debian': {
|
||||
package { 'nginx':
|
||||
ensure => 'latest'
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported platform: ${osfamily}/${operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
# Start the service
|
||||
service { 'nginx':
|
||||
enable => 'true',
|
||||
ensure => 'running'
|
||||
}
|
11
examples/kitchen-puppet/metadata.json
Normal file
11
examples/kitchen-puppet/metadata.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "prepare",
|
||||
"version": "0.1.0",
|
||||
"author": "support@chef.io",
|
||||
"summary": "This module prepares the test operating systems",
|
||||
"license": "Apache-2.0",
|
||||
"source": "https://github.com/chef/inspec/examples/kitchen-puppet",
|
||||
"project_page": "https://github.com/chef/inspec/examples/kitchen-puppet",
|
||||
"issues_url": "https://github.com/chef/inspec/issues",
|
||||
"dependencies": []
|
||||
}
|
28
examples/kitchen-puppet/test/integration/default/web_spec.rb
Normal file
28
examples/kitchen-puppet/test/integration/default/web_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# encoding: utf-8
|
||||
# author: Christoph Hartmann
|
||||
# author: Dominik Richter
|
||||
|
||||
# use basic tests
|
||||
describe package('nginx') do
|
||||
it { should be_installed }
|
||||
end
|
||||
|
||||
# extend tests with metadata
|
||||
control '01' do
|
||||
impact 0.7
|
||||
title 'Verify nginx service'
|
||||
desc 'Ensures nginx service is up and running'
|
||||
describe service('nginx') do
|
||||
it { should be_enabled }
|
||||
it { should be_installed }
|
||||
it { should be_running }
|
||||
end
|
||||
end
|
||||
|
||||
# implement os dependent tests
|
||||
web_user = 'www-data'
|
||||
web_user = 'nginx' if os[:family] == 'centos'
|
||||
|
||||
describe user(web_user) do
|
||||
it { should exist }
|
||||
end
|
Loading…
Reference in a new issue