Introduce Puppet-lint/syntax test into Packstack

- Add puppet-lint and puppet-syntax
- To run puppet-lint, please look at the README.md file.

Change-Id: I4b9e5d0c030b891545bc07f10091d748cdc1482e
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
Gael Chamoulaud 2014-11-12 17:36:08 +01:00
parent 9be16f3ee5
commit b2c341d4a5
4 changed files with 67 additions and 0 deletions

2
.gitignore vendored
View File

@ -2,4 +2,6 @@
*.swp
*.log
.tox
vendor/*
Gemfile.lock
packstack.egg-info

17
Gemfile Normal file
View File

@ -0,0 +1,17 @@
source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 1.1'
gem 'puppet-lint-param-docs', '1.1.0'
gem 'puppet-syntax'
gem 'rake', '10.1.1'
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
# vim:ft=ruby

View File

@ -131,3 +131,31 @@ executable without further intervention, and **Packstack** is ready to install.
**IMPORTANT** <https://docs.puppetlabs.com/guides/style_guide.html>
Please, respect the Puppet Style Guide as much as possible !
## Running local Puppet-lint tests
It assumes that both `bundler` as well as `rubygems` (and `ruby`) are already
installed on the system. If not, run this command:
$ sudo yum install rubygems rubygem-bundler ruby ruby-devel -y
Go into the **Packstack** root directory.
$ cd packstack/
A `Rakefile` contains all you need to run puppet-lint task automatically over
all the puppet manifests included in the **Packstack** project.
$ ls -l packstack/puppet/templates/
and
$ ls -l packstack/puppet/modules/
The default puppet-lint pattern for `.pp` files is `**/*.pp`. So there is no
need to go inside those directories to run puppet-lint !
$ mkdir vendor
$ export GEM_HOME=vendor
$ bundle install
$ bundle exec rake lint

20
Rakefile Normal file
View File

@ -0,0 +1,20 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.with_filename = false
PuppetLint.configuration.send('disable_names_containing_dash')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_parameter_defaults')
exclude_paths = ['spec/**/*','pkg/**/*','vendor/**/*']
exclude_lint_paths = exclude_paths
PuppetLint.configuration.ignore_paths = exclude_lint_paths
PuppetSyntax.exclude_paths = exclude_paths
task(:default).clear
task :default => :lint
desc 'Run syntax, lint'
task :test => [:syntax,:lint]