Merge pull request #1 from bashtoni/master

Working spec tests + cleanups
This commit is contained in:
gdhbashton 2015-01-30 11:18:21 +00:00
Родитель 4c3795198d 96e55502e9
Коммит c5b3ed6b77
50 изменённых файлов: 684 добавлений и 938 удалений

Просмотреть файл

@ -2,5 +2,6 @@ fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
staging: "https://github.com/nanliu/puppet-staging.git"
concat: "https://github.com/puppetlabs/puppet-concat.git"
symlinks:
consul: "#{source_dir}"

4
.gitignore поставляемый
Просмотреть файл

@ -2,4 +2,6 @@
pkg
spec/fixtures
.rspec_system
Gemfile.lock
.vagrant
.bundle
vendor

Просмотреть файл

@ -1,35 +1,31 @@
---
language: ruby
bundler_args: --without development
bundler_args: --without development system_tests
before_install: rm Gemfile.lock || true
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.0
script: bundle exec rake test
env:
- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION="~> 3.1.0"
- PUPPET_VERSION="~> 3.2.0"
- PUPPET_VERSION="~> 3.3.0"
- PUPPET_VERSION="~> 3.4.0"
- PUPPET_VERSION="~> 3.5.0"
- PUPPET_VERSION="~> 3.7.0"
- PUPPET_VERSION="~> 3.2.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 3.3.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 3.4.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 3.5.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 3.6.0" STRICT_VARIABLES=yes
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.1.0"
env: PUPPET_VERSION="~> 3.2.0" STRICT_VARIABLES=yes
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.2.0"
env: PUPPET_VERSION="~> 3.3.0" STRICT_VARIABLES=yes
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.4.0"
env: PUPPET_VERSION="~> 3.4.0" STRICT_VARIABLES=yes

3
CHANGELOG Normal file
Просмотреть файл

@ -0,0 +1,3 @@
YYYY-MM-DD Release 0.1.0
- something you did
- something else you did

92
CONTRIBUTING.md Normal file
Просмотреть файл

@ -0,0 +1,92 @@
This module has grown over time based on a range of contributions from
people using it. If you follow these contributing guidelines your patch
will likely make it into a release a little quicker.
## Contributing
1. Fork the repo.
2. Run the tests. We only take pull requests with passing tests, and
it's great to know that you have a clean slate.
3. Add a test for your change. Only refactoring and documentation
changes require no new tests. If you are adding functionality
or fixing a bug, please add a test.
4. Make the test pass.
5. Push to your fork and submit a pull request.
## Dependencies
The testing and development tools have a bunch of dependencies,
all managed by [Bundler](http://bundler.io/) according to the
[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions).
By default the tests use a baseline version of Puppet.
If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as:
export PUPPET_VERSION="~> 3.2.0"
Install the dependencies like so...
bundle install
## Syntax and style
The test suite will run [Puppet Lint](http://puppet-lint.com/) and
[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
check various syntax and style things. You can run these locally with:
bundle exec rake lint
bundle exec rake syntax
## Running the unit tests
The unit test suite covers most of the code, as mentioned above please
add tests if you're adding new functionality. If you've not used
[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask
about how best to test your new feature. Running the test suite is done
with:
bundle exec rake spec
Note also you can run the syntax, style and unit tests in one go with:
bundle exec rake test
### Automatically run the tests
During development of your puppet module you might want to run your unit
tests a couple of times. You can use the following command to automate
running the unit tests on every change made in the manifests folder.
bundle exec guard
## Integration tests
The unit tests just check the code runs, not that it does exactly what
we want on a real machine. For that we're using
[Beaker](https://github.com/puppetlabs/beaker).
Beaker fires up a new virtual machine (using Vagrant) and runs a series of
simple tests against it after applying the module. You can run our
Beaker tests with:
bundle exec rake acceptance
This will use the host described in `spec/acceptance/nodeset/default.yml`
by default. To run against another host, set the `RS_SET` environment
variable to the name of a host described by a `.yml` file in the
`nodeset` directory. For example, to run against CentOS 6.4:
RS_SET=centos-64-x64 bundle exec rake acceptance
If you don't want to have to recreate the virtual machine every time you
can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will
at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile
for the created virtual machines will be in `.vagrant/beaker_vagrant_files`.

1
CONTRIBUTORS Normal file
Просмотреть файл

@ -0,0 +1 @@
gdhbashton

22
Gemfile
Просмотреть файл

@ -1,19 +1,21 @@
source "http://rubygems.org"
source "https://rubygems.org"
group :test do
gem "rake"
gem 'beaker', '~> 1.11.0'
gem "puppet-blacksmith"
gem "puppet", '~> 3.7.0'
gem "puppet-lint"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.0'
gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git'
gem "puppet-syntax"
gem "puppetlabs_spec_helper"
gem "hiera-puppet-helper"
gem "metadata-json-lint"
end
group :development do
gem 'json'
gem 'beaker', '~> 1.11.0'
gem 'beaker-rspec'
gem "travis"
gem "travis-lint"
gem "vagrant-wrapper"
gem "puppet-blacksmith"
gem "guard-rake"
end
group :system_tests do
gem "beaker"
end

312
Gemfile.lock Normal file
Просмотреть файл

@ -0,0 +1,312 @@
GIT
remote: https://github.com/rodjek/rspec-puppet.git
revision: 8459e14807977244c00bdbcf190062c529b63474
specs:
rspec-puppet (2.0.0)
rspec (~> 2.0)
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.8)
activesupport (4.2.0)
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.6)
archive-tar-minitar (0.5.2)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
multi_json (>= 1.0.0)
aws-sdk (1.61.0)
aws-sdk-v1 (= 1.61.0)
aws-sdk-v1 (1.61.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
backports (3.6.4)
beaker (2.3.0)
aws-sdk (~> 1.57)
docker-api
fission (~> 0.4)
fog (~> 1.25)
google-api-client (~> 0.7)
hocon (~> 0.0.4)
inifile (~> 2.0)
json (~> 1.8)
minitest (~> 5.4)
net-scp (~> 1.2)
net-ssh (~> 2.9)
rbvmomi (~> 1.8)
unf (~> 0.1)
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
diff-lcs (1.2.5)
docker-api (1.17.0)
archive-tar-minitar
excon (>= 0.38.0)
json
ethon (0.7.2)
ffi (>= 1.3.0)
excon (0.43.0)
extlib (0.9.16)
facter (2.4.0)
CFPropertyList (~> 2.2.6)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.6)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.27.0)
fog-atmos
fog-aws (~> 0.0)
fog-brightbox (~> 0.4)
fog-core (~> 1.27, >= 1.27.3)
fog-ecloud
fog-json
fog-profitbricks
fog-radosgw (>= 0.0.2)
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.0.8)
fog-core (~> 1.27)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-brightbox (0.7.1)
fog-core (~> 1.22)
fog-json
inflecto (~> 0.0.2)
fog-core (1.27.4)
builder
excon (~> 0.38)
formatador (~> 0.2)
mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
fog-ecloud (0.0.2)
fog-core
fog-xml
fog-json (1.0.0)
multi_json (~> 1.0)
fog-profitbricks (0.0.1)
fog-core
fog-xml
nokogiri
fog-radosgw (0.0.3)
fog-core (>= 1.21.0)
fog-json
fog-xml (>= 0.0.1)
fog-sakuracloud (1.0.0)
fog-core
fog-json
fog-serverlove (0.1.1)
fog-core
fog-json
fog-softlayer (0.4.0)
fog-core
fog-json
fog-storm_on_demand (0.1.0)
fog-core
fog-json
fog-terremark (0.0.3)
fog-core
fog-xml
fog-vmfusion (0.0.1)
fission
fog-core
fog-voxel (0.0.2)
fog-core
fog-xml
fog-xml (0.1.1)
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.2)
activesupport (>= 3.2)
addressable (~> 2.3)
autoparse (~> 0.3)
extlib (~> 0.9)
faraday (~> 0.9)
launchy (~> 2.4)
multi_json (~> 1.10)
retriable (~> 1.4)
signet (~> 0.6)
guard (2.11.1)
formatador (>= 0.2.4)
listen (~> 2.7)
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.6.21)
hitimes (1.2.2)
hocon (0.0.7)
i18n (0.7.0)
inflecto (0.0.2)
inifile (2.0.2)
ipaddress (0.8.0)
json (1.8.2)
json_pure (1.8.2)
jwt (1.2.1)
launchy (2.4.3)
addressable (~> 2.3)
listen (2.8.5)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
metaclass (0.0.4)
metadata-json-lint (0.0.5)
json
semantic (~> 1.0)
spdx-licenses (~> 1.0)
method_source (0.8.2)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
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)
netrc (0.10.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
notiffany (0.0.3)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
puppet (3.7.4)
facter (> 1.6, < 3)
hiera (~> 1.0)
json_pure
puppet-blacksmith (3.1.1)
puppet (>= 2.7.16)
rest-client
puppet-lint (1.1.0)
puppet-syntax (1.4.1)
rake
puppetlabs_spec_helper (0.8.2)
mocha
puppet-lint
puppet-syntax
rake
rspec
rspec-puppet
pusher-client (0.6.0)
json
websocket (~> 1.0)
rake (10.4.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rbvmomi (1.8.2)
builder
nokogiri (>= 1.4.1)
trollop
rest-client (1.7.2)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
retriable (1.4.1)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.99.3)
semantic (1.4.0)
shellany (0.0.1)
signet (0.6.0)
addressable (~> 2.3)
extlib (~> 0.9)
faraday (~> 0.9)
jwt (~> 1.0)
multi_json (~> 1.10)
slop (3.6.0)
spdx-licenses (1.0.0)
json
thor (0.19.1)
thread_safe (0.3.4)
timers (4.0.1)
hitimes
travis (1.7.5)
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.1)
typhoeus (0.7.1)
ethon (>= 0.7.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.6)
vagrant-wrapper (2.0.2)
websocket (1.2.1)
PLATFORMS
ruby
DEPENDENCIES
beaker
guard-rake
metadata-json-lint
puppet (~> 3.7.0)
puppet-blacksmith
puppetlabs_spec_helper
rake
rspec-puppet!
travis
travis-lint
vagrant-wrapper

5
Guardfile Normal file
Просмотреть файл

@ -0,0 +1,5 @@
notification :off
guard 'rake', :task => 'test' do
watch(%r{^manifests\/(.+)\.pp$})
end

10
Modulefile Normal file
Просмотреть файл

@ -0,0 +1,10 @@
name 'puppet-consul_template'
version '0.1.0'
source 'https://github.com/gdhbashton/puppet-consul_template'
author 'gdhbashton'
license 'Apache 2.0'
summary 'Install and manage Consul Template and its jobs'
description ''
project_page 'https://github.com/gdhbashton/puppet-consul_template'
dependency 'puppetlabs/stdlib'

Просмотреть файл

@ -33,9 +33,6 @@ consul_template::watch { 'common':
Depends on the JSON gem, or a modern ruby.
##Thanks
To solarkennedy whose consul module I shamelessly based this one on.
##Development
Open an [issue](https://github.com/gdhbashton/puppet-consul_template/issues) or
[fork](https://github.com/gdhbashton/puppet-consul_template/fork) and open a

Просмотреть файл

@ -1,15 +1,18 @@
require 'bundler/setup'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet/vendor/semantic/lib/semantic'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
# These two gems aren't always present, for instance
# These gems aren't always present, for instance
# on Travis with --without development
begin
require 'puppet_blacksmith/rake_tasks'
rescue LoadError
end
Rake::Task[:lint].clear
PuppetLint.configuration.relative = true
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
PuppetLint.configuration.fail_on_warnings = true
@ -21,6 +24,7 @@ PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
exclude_paths = [
"bundle/**/*",
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
@ -33,9 +37,14 @@ RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end
task :metadata do
sh "metadata-json-lint metadata.json"
end
desc "Run syntax, lint, and spec tests."
task :test => [
:syntax,
# :lint,
:lint,
:spec,
:metadata,
]

Просмотреть файл

0
lib/puppet/type/.gitkeep Normal file
Просмотреть файл

Просмотреть файл

@ -1,8 +1,8 @@
# == Class consul_template::config
#
# This class is called from consul_template
# This class is called from consul_template for service config.
#
class consul_template::config(
class consul_template::config (
$consul_host,
$consul_port,
$consul_token,

Просмотреть файл

@ -1,4 +1,4 @@
# == Class: consul-template
# == Class: consul_template
#
# Installs, configures, and manages consul-template
#
@ -24,12 +24,9 @@
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
class consul_template (
$manage_user = true,
$user = 'consul-t',
$manage_group = true,
$purge_config_dir = true,
$group = 'consul-t',
$bin_dir = '/usr/local/bin',
$arch = $consul_template::params::arch,
$version = $consul_template::params::version,
@ -47,20 +44,18 @@ class consul_template (
$consul_token = '',
$consul_retry = '10s',
$init_style = $consul_template::params::init_style,
) inherits consul_template::params {
) inherits ::consul_template::params {
validate_bool($purge_config_dir)
validate_bool($manage_user)
class { 'consul_template::install': } ->
class { 'consul_template::config':
class { '::consul_template::install': } ->
class { '::consul_template::config':
consul_host => $consul_host,
consul_port => $consul_port,
consul_token => $consul_token,
consul_retry => $consul_retry,
purge => $purge_config_dir,
} ~>
class { 'consul_template::run_service': } ->
Class['consul_template']
class { '::consul_template::service': } ->
Class['::consul_template']
}

Просмотреть файл

@ -1,7 +1,7 @@
# == Class consul_template::params
#
# This class is meant to be called from consul_template
# It sets variables according to platform
# This class is meant to be called from consul_template.
# It sets variables according to platform.
#
class consul_template::params {
@ -33,6 +33,6 @@ class consul_template::params {
default => 'systemd',
},
'Debian' => 'debian',
default => undef
default => 'sysv'
}
}

Просмотреть файл

@ -1,9 +1,9 @@
# == Class consul_template::service
#
# This class is meant to be called from consul_template
# It ensure the service is running
# This class is meant to be called from consul_template.
# It ensure the service is running.
#
class consul_template::run_service {
class consul_template::service {
service { 'consul-template':
ensure => $consul_template::service_ensure,
@ -11,4 +11,5 @@ class consul_template::run_service {
name => 'consul-template',
}
}

Просмотреть файл

@ -1,6 +1,6 @@
# == Class consul_template::watch
# == Definition consul_template::watch
#
# This class is called from consul_template
# This definition is called from consul_template
# This is a single instance of a configuration file to watch
# for changes in Consul and update the local file
define consul_template::watch (

Просмотреть файл

@ -1,9 +1,9 @@
{
"name": "gdhbashton-consul_template",
"version": "0.1.3",
"author": "Gavin Hamill <gdh@bashton.com>",
"license": "GPL-2.0",
"name": "puppet-consul_template",
"version": "0.2.0",
"author": "gdhbashton",
"summary": "Install and manage Consul Template and its jobs",
"license": "Apache-2.0",
"source": "https://github.com/gdhbashton/puppet-consul_template",
"project_page": "https://github.com/gdhbashton/puppet-consul_template",
"issues_url": "https://github.com/gdhbashton/puppet-consul_template/issues",

Просмотреть файл

@ -0,0 +1,26 @@
require 'spec_helper_acceptance'
describe 'consul_template class' do
context 'default parameters' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'consul_template': }
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe package('consul_template') do
it { is_expected.to be_installed }
end
describe service('consul_template') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
centos-511-x64:
roles:
- master
platform: el-5-x86_64
box: puppetlabs/centos-5.11-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-5.11-64-nocm
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,11 @@
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
centos-65-x64:
roles:
- master
platform: el-6-x86_64
box: puppetlabs/centos-6.5-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-6.5-64-nocm
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
centos-7-x64:
roles:
- master
platform: el-7-x86_64
box: chef/centos-7.0
box_url: https://vagrantcloud.com/chef/boxes/centos-7.0
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
debian-609-x64:
roles:
- master
platform: debian-6-amd64
box: puppetlabs/debian-6.0.9-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/debian-6.0.9-64-nocm
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
debian-76-x64:
roles:
- master
platform: debian-7-amd64
box: puppetlabs/debian-7.6-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/debian-7.6-64-nocm
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -1,7 +1,12 @@
HOSTS:
ubuntu-12-04:
platform: ubuntu-12.04-x64
image: solarkennedy/ubuntu-12.04-puppet
hypervisor: docker
CONFIG:
ubuntu-server-1204-x64:
roles:
- master
platform: ubuntu-1204-amd64
box: puppetlabs/ubuntu-12.04-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-12.04-64-nocm
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
fedora-20-x64:
roles:
- master
platform: el-7-x86_64
box: chef/fedora-20
box_url: https://vagrantcloud.com/chef/boxes/fedora-20
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
ubuntu-server-1204-x64:
roles:
- master
platform: ubuntu-1204-amd64
box: puppetlabs/ubuntu-12.04-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-12.04-64-nocm
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
ubuntu-server-12042-x64:
roles:
- master
platform: ubuntu-server-12.04-amd64
box: ubuntu-server-12042-x64-vbox4210-nocm
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -0,0 +1,12 @@
HOSTS:
ubuntu-server-1404-x64:
roles:
- master
platform: ubuntu-1404-amd64
box: puppetlabs/ubuntu-14.04-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-14.04-64-nocm
hypervisor: vagrant
CONFIG:
log_level: verbose
type: foss

Просмотреть файл

@ -1,38 +0,0 @@
require 'spec_helper_acceptance'
describe 'consul class' do
context 'default parameters' do
# Using puppet_apply as a helper
it 'should work with no errors based on the example' do
pp = <<-EOS
class { 'consul':
config_hash => {
'datacenter' => 'east-aws',
'data_dir' => '/opt/consul',
'log_level' => 'INFO',
'node_name' => 'foobar',
'server' => true
}
}
EOS
# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
describe file('/opt/consul') do
it { should be_directory }
end
describe service('consul') do
it { should be_enabled }
end
describe command('consul version') do
it { should return_stdout /Consul v0\.4\.1/ }
end
end
end

Просмотреть файл

@ -1,46 +0,0 @@
require 'spec_helper_acceptance'
describe 'consul class' do
context 'UI parameters' do
# Using puppet_apply as a helper
it 'should work with no errors based on the UI example' do
pp = <<-EOS
class { 'consul':
config_hash => {
'datacenter' => 'east-aws',
'data_dir' => '/opt/consul',
'ui_dir' => '/opt/consul/ui',
'client_addr' => '0.0.0.0',
'log_level' => 'INFO',
'node_name' => 'foobar',
'server' => true
}
}
EOS
# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
describe file('/opt/consul') do
it { should be_directory }
end
describe file('/opt/consul/ui') do
it { should be_linked_to '/opt/consul/0.4.1_web_ui' }
end
describe service('consul') do
it { should be_enabled }
end
it { should contain_service('mysql-server').with_ensure('present') }
describe command('consul version') do
it { should return_stdout /Consul v0\.4\.1/ }
end
end
end

Просмотреть файл

@ -1,10 +0,0 @@
#require 'spec_helper_acceptance'
#
#describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
# it 'should fail' do
# pp = <<-EOS
# class { 'consul': }
# EOS
# expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i)
# end
#end

Просмотреть файл

@ -0,0 +1 @@
at_exit { RSpec::Puppet::Coverage.report! }

Просмотреть файл

@ -0,0 +1,26 @@
require 'spec_helper'
describe 'consul_template' do
context 'supported operating systems' do
['Debian', 'RedHat'].each do |osfamily|
describe "consul_template class without any parameters on #{osfamily}" do
let(:params) {{ }}
let(:facts) {{
:osfamily => osfamily,
:concat_basedir => '/foo',
:path => '/bin:/sbin:/usr/bin:/usr/sbin',
:architecture => 'x86_64'
}}
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('consul_template::params') }
it { is_expected.to contain_class('consul_template::install').that_comes_before('consul_template::config') }
it { is_expected.to contain_class('consul_template::config') }
it { is_expected.to contain_class('consul_template::service').that_subscribes_to('consul_template::config') }
it { is_expected.to contain_service('consul-template') }
end
end
end
end

Просмотреть файл

@ -1,304 +0,0 @@
require 'spec_helper'
describe 'consul' do
RSpec.configure do |c|
c.default_facts = {
:architecture => 'x86_64',
:operatingsystem => 'Ubuntu',
:lsbdistrelease => '10.04',
:kernel => 'Linux',
}
end
# Installation Stuff
context 'On an unsupported arch' do
let(:facts) {{ :architecture => 'bogus' }}
let(:params) {{
:install_method => 'package'
}}
it { expect { should compile }.to raise_error(/Unsupported kernel architecture:/) }
end
context 'When not specifying whether to purge config' do
it { should contain_file('/etc/consul').with(:purge => true,:recurse => true) }
end
context 'When passing a non-bool as purge_config_dir' do
let(:params) {{
:purge_config_dir => 'hello'
}}
it { expect { should compile }.to raise_error(/is not a boolean/) }
end
context 'When disable config purging' do
let(:params) {{
:purge_config_dir => false
}}
it { should contain_class('consul::config').with(:purge => false) }
end
context 'When joining consul to a wan cluster by a known URL' do
let(:params) {{
:join_wan => 'wan_host.test.com'
}}
it { should contain_exec('join consul wan').with(:command => 'consul join -wan wan_host.test.com') }
end
context 'By default, should not attempt to join a wan cluster' do
it { should_not contain_exec('join consul wan') }
end
context 'When requesting to install via a package with defaults' do
let(:params) {{
:install_method => 'package'
}}
it { should contain_package('consul').with(:ensure => 'latest') }
end
context 'When requesting to install via a custom package and version' do
let(:params) {{
:install_method => 'package',
:package_ensure => 'specific_release',
:package_name => 'custom_consul_package'
}}
it { should contain_package('custom_consul_package').with(:ensure => 'specific_release') }
end
context "When installing via URL by default" do
it { should contain_staging__file('consul.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip') }
end
context "When installing via URL by with a special version" do
let(:params) {{
:version => '42',
}}
it { should contain_staging__file('consul.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/42_linux_amd64.zip') }
end
context "When installing via URL by with a custom url" do
let(:params) {{
:download_url => 'http://myurl',
}}
it { should contain_staging__file('consul.zip').with(:source => 'http://myurl') }
end
context 'When requesting to install via a package with defaults' do
let(:params) {{
:install_method => 'package'
}}
it { should contain_package('consul').with(:ensure => 'latest') }
end
context 'When requesting to install UI via a custom package and version' do
let(:params) {{
:install_method => 'package',
:ui_package_ensure => 'specific_ui_release',
:ui_package_name => 'custom_consul_ui_package',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_package('custom_consul_ui_package').with(:ensure => 'specific_ui_release') }
end
context "When installing UI via URL by default" do
let(:params) {{
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_staging__file('consul_web_ui.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/0.4.1_web_ui.zip') }
end
context "When installing UI via URL by with a special version" do
let(:params) {{
:version => '42',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_staging__file('consul_web_ui.zip').with(:source => 'https://dl.bintray.com/mitchellh/consul/42_web_ui.zip') }
end
context "When installing UI via URL by with a custom url" do
let(:params) {{
:ui_download_url => 'http://myurl',
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_staging__deploy('consul_web_ui.zip').with(:source => 'http://myurl') }
end
context "By default, a user and group should be installed" do
it { should contain_user('consul').with(:ensure => :present) }
it { should contain_group('consul').with(:ensure => :present) }
end
context "When data_dir is provided" do
let(:params) {{
:config_hash => {
'data_dir' => '/dir1',
},
}}
it { should contain_file('/dir1').with(:ensure => :directory) }
end
context "When data_dir not provided" do
it { should_not contain_file('/dir1').with(:ensure => :directory) }
end
context "When ui_dir is provided but not data_dir" do
let(:params) {{
:config_hash => {
'ui_dir' => '/dir1/dir2',
},
}}
it { should_not contain_file('/dir1/dir2') }
end
context "When ui_dir and data_dir is provided" do
let(:params) {{
:config_hash => {
'data_dir' => '/dir1',
'ui_dir' => '/dir1/dir2',
},
}}
it { should contain_file('/dir1') }
it { should contain_file('/dir1/dir2') }
end
context 'The bootstrap_expect in config_hash is an int' do
let(:params) {{
:config_hash =>
{ 'bootstrap_expect' => '5' }
}}
it { should contain_file('config.json').with_content(/"bootstrap_expect":5/) }
it { should_not contain_file('config.json').with_content(/"bootstrap_expect":"5"/) }
end
context 'Config_defaults is used to provide additional config' do
let(:params) {{
:config_defaults => {
'data_dir' => '/dir1',
},
:config_hash => {
'bootstrap_expect' => '5',
}
}}
it { should contain_file('config.json').with_content(/"bootstrap_expect":5/) }
it { should contain_file('config.json').with_content(/"data_dir":"\/dir1"/) }
end
context 'Config_defaults is used to provide additional config and is overridden' do
let(:params) {{
:config_defaults => {
'data_dir' => '/dir1',
'server' => false,
},
:config_hash => {
'bootstrap_expect' => '5',
'server' => true,
}
}}
it { should contain_file('config.json').with_content(/"bootstrap_expect":5/) }
it { should contain_file('config.json').with_content(/"data_dir":"\/dir1"/) }
it { should contain_file('config.json').with_content(/"server":true/) }
end
context "When asked not to manage the user" do
let(:params) {{ :manage_user => false }}
it { should_not contain_user('consul') }
end
context "When asked not to manage the group" do
let(:params) {{ :manage_group => false }}
it { should_not contain_group('consul') }
end
context "With a custom username" do
let(:params) {{
:user => 'custom_consul_user',
:group => 'custom_consul_group',
}}
it { should contain_user('custom_consul_user').with(:ensure => :present) }
it { should contain_group('custom_consul_group').with(:ensure => :present) }
it { should contain_file('/etc/init/consul.conf').with_content(/sudo -u custom_consul_user -g custom_consul_group/) }
end
context "On a redhat 6 based OS" do
let(:facts) {{
:operatingsystem => 'CentOS',
:operatingsystemmajrelease => 6,
}}
it { should contain_class('consul').with_init_style('sysv') }
it { should contain_file('/etc/init.d/consul').with_content(/daemon --user=consul/) }
end
context "On a redhat 7 based OS" do
let(:facts) {{
:operatingsystem => 'CentOS',
:operatingsystemmajrelease => 7,
}}
it { should contain_class('consul').with_init_style('systemd') }
it { should contain_file('/lib/systemd/system/consul.service').with_content(/consul agent/) }
end
context "On a fedora 20 based OS" do
let(:facts) {{
:operatingsystem => 'Fedora',
:operatingsystemmajrelease => 20,
}}
it { should contain_class('consul').with_init_style('systemd') }
it { should contain_file('/lib/systemd/system/consul.service').with_content(/consul agent/) }
end
context "On hardy" do
let(:facts) {{
:operatingsystem => 'Ubuntu',
:lsbdistrelease => '8.04',
}}
it { should contain_class('consul').with_init_style('debian') }
it {
should contain_file('/etc/init.d/consul')
.with_content(/start-stop-daemon .* \$DAEMON/)
.with_content(/DAEMON_ARGS="agent/)
.with_content(/--user \$USER/)
}
end
context "When asked not to manage the init_style" do
let(:params) {{ :init_style => false }}
it { should contain_class('consul').with_init_style(false) }
it { should_not contain_file("/etc/init.d/consul") }
it { should_not contain_file("/lib/systemd/system/consul.service") }
end
context "On squeeze" do
let(:facts) {{
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.1'
}}
it { should contain_class('consul').with_init_style('debian') }
end
# Config Stuff
context "With extra_options" do
let(:params) {{
:extra_options => '-some-extra-argument'
}}
it { should contain_file('/etc/init/consul.conf').with_content(/\$CONSUL agent .*-some-extra-argument$/) }
end
# Service Stuff
end

Просмотреть файл

@ -1,66 +0,0 @@
require 'spec_helper'
describe 'consul::check' do
let(:facts) {{ :architecture => 'x86_64' }}
let(:title) { "my_check" }
describe 'with no args' do
let(:params) {{}}
it {
expect { should raise_error(Puppet::Error) }
}
end
describe 'with interval' do
let(:params) {{
'interval' => '30s',
'script' => 'true'
}}
it {
should contain_file("/etc/consul/check_my_check.json") \
.with_content(/"id" *: *"my_check"/)
.with_content(/"name" *: *"my_check"/)
.with_content(/"check" *: *{/)
.with_content(/"interval" *: *"30s"/)
.with_content(/"script" *: *"true"/)
}
end
describe 'with ttl' do
let(:params) {{
'ttl' => '30s',
}}
it {
should contain_file("/etc/consul/check_my_check.json") \
.with_content(/"id" *: *"my_check"/)
.with_content(/"name" *: *"my_check"/)
.with_content(/"check" *: *{/)
.with_content(/"ttl" *: *"30s"/)
}
end
describe 'with both ttl and interval' do
let(:params) {{
'ttl' => '30s',
'interval' => '60s'
}}
it {
expect { should raise_error(Puppet::Error) }
}
end
describe 'with both ttl and script' do
let(:params) {{
'ttl' => '30s',
'script' => 'true'
}}
it {
expect { should raise_error(Puppet::Error) }
}
end
describe 'with interval but no script' do
let(:params) {{
'interval' => '30s',
}}
it {
expect { should raise_error(Puppet::Error) }
}
end
end

Просмотреть файл

@ -1,91 +0,0 @@
require 'spec_helper'
describe 'consul::service' do
let(:facts) {{ :architecture => 'x86_64' }}
let(:title) { "my_service" }
describe 'with no args' do
let(:params) {{}}
it {
should contain_file("/etc/consul/service_my_service.json")
.with_content(/"service" *: *{/)
.with_content(/"id" *: *"my_service"/)
.with_content(/"name" *: *"my_service"/)
}
end
describe 'with service name' do
let(:params) {{
'service_name' => 'different_name',
}}
it {
should contain_file("/etc/consul/service_my_service.json")
.with_content(/"service" *: *{/)
.with_content(/"id" *: *"my_service"/)
.with_content(/"name" *: *"different_name"/)
}
end
describe 'with interval' do
let(:params) {{
'check_interval' => '30s',
'check_script' => 'true'
}}
it {
should contain_file("/etc/consul/service_my_service.json") \
.with_content(/"check" *: *{/)
.with_content(/"interval" *: *"30s"/)
.with_content(/"script" *: *"true"/)
}
end
describe 'with ttl' do
let(:params) {{
'check_ttl' => '30s',
}}
it {
should contain_file("/etc/consul/service_my_service.json") \
.with_content(/"check" *: *{/)
.with_content(/"ttl" *: *"30s"/)
}
end
describe 'with both ttl and interval' do
let(:params) {{
'check_ttl' => '30s',
'check_interval' => '60s'
}}
it {
expect { should raise_error(Puppet::Error) }
}
end
describe 'with port' do
let(:params) {{
'check_ttl' => '30s',
'port' => 5,
}}
it {
should contain_file("/etc/consul/service_my_service.json")
.with_content(/"port":5/)
}
it {
should_not contain_file("/etc/consul/service_my_service.json")
.with_content(/"port":"5"/)
}
end
describe 'with both ttl and script' do
let(:params) {{
'check_ttl' => '30s',
'check_script' => 'true'
}}
it {
expect { should raise_error(Puppet::Error) }
}
end
describe 'with interval but no script' do
let(:params) {{
'interval' => '30s',
}}
it {
expect { should raise_error(Puppet::Error) }
}
end
end

Просмотреть файл

@ -1,282 +0,0 @@
require 'spec_helper'
describe 'consul::watch' do
let(:facts) {{ :architecture => 'x86_64', :version => '0.4.0' }}
let(:title) { "my_watch" }
describe 'version checks' do
context 'with version < 0.4.0' do
let (:facts) {{ :architecture => 'x86_64' }}
let(:hiera_data) {{ 'consul::version' => '0.3.0' }}
let (:params) {{
'type' => 'nodes',
'handler' => 'handler_path',
}}
it {
expect {
should contain_file('/etc/consul/watch_my_watch.json')
}.to raise_error(Puppet::Error, /Watches are only supported in Consul 0.4.0 and above/)
}
end
context 'with version 0.4.1' do
let (:facts) {{ :architecture => 'x86_64' }}
let(:hiera_data) {{ 'consul::version' => '0.4.1' }}
let (:params) {{
'type' => 'nodes',
'handler' => 'handler_path',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json')
}
end
context 'with version 1.3.0' do
let (:facts) {{ :architecture => 'x86_64' }}
let(:hiera_data) {{ 'consul::version' => '1.3.0' }}
let (:params) {{
'type' => 'nodes',
'handler' => 'handler_path',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json')
}
end
end
describe 'with no args' do
let(:params) {{}}
it {
expect { should raise_error(Puppet::Error)}
}
end
describe 'with handler no type' do
let(:params) {{
'handler' => 'handler_path',
}}
it {
expect { should raise_error(Puppet::Error)}
}
end
describe 'with valid type no handler' do
let(:params) {{
'type' => 'nodes',
}}
it {
expect { should raise_error(Puppet::Error)}
}
end
describe 'with valid type and handler' do
let(:params) {{
'type' => 'nodes',
'handler' => 'handler_path',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"handler" *: *"handler_path"/)
.with_content(/"type" *: *"nodes"/)
}
end
describe 'global attributes' do
let (:params) {{
'type' => 'nodes',
'handler' => 'handler_path',
'datacenter' => 'dcName',
'token' => 'tokenValue',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"datacenter" *: *"dcName"/)
.with_content(/"token" *: *"tokenValue"/)
}
end
describe 'type validation' do
context '"key" type' do
context 'without key' do
let (:params) {{
'type' => 'key',
'handler' => 'handler_path'
}}
it {
expect { should raise_error(Puppet::Error)}
}
end
context 'with key' do
let (:params) {{
'type' => 'key',
'handler' => 'handler_path',
'key' => 'KeyName',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"type" *: *"key"/)
.with_content(/"key" *: *"KeyName"/)
}
end
end
context '"keyprefix" type' do
context 'without keyprefix' do
let (:params) {{
'type' => 'keyprefix',
'handler' => 'handler_path'
}}
it {
expect { should raise_error(Puppet::Error)}
}
end
context 'with keyprefix' do
let (:params) {{
'type' => 'keyprefix',
'handler' => 'handler_path',
'keyprefix' => 'keyPref',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"type" *: *"keyprefix"/)
.with_content(/"keyprefix" *: *"keyPref"/)
}
end
end
context '"service" type' do
context 'without service' do
let (:params) {{
'type' => 'service',
'handler' => 'handler_path',
}}
it {
expect { should raise_error(Puppet::Error) }
}
end
context 'with service' do
let (:params) {{
'type' => 'service',
'handler' => 'handler_path',
'service' => 'serviceName',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"type" *: *"service"/)
.with_content(/"service" *: *"serviceName"/)
}
end
context 'with all optionals' do
let (:params) {{
'type' => 'service',
'handler' => 'handler_path',
'service' => 'serviceName',
'service_tag' => 'serviceTagName',
'passingonly' => 'true'
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"tag" *: *"serviceTagName"/)
.with_content(/"passingonly" *: *"true"/)
}
end
end
context '"checks" type' do
context 'without optionals' do
let (:params) {{
'type' => 'checks',
'handler' => 'handler_path',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"type" *: *"checks"/)
}
end
context 'with all optionals' do
let (:params) {{
'type' => 'checks',
'handler' => 'handler_path',
'service' => 'serviceName',
'state' => 'serviceState',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"service" *: *"serviceName"/)
.with_content(/"state" *: *"serviceState"/)
}
end
end
context '"event" type' do
context 'without optionals' do
let (:params) {{
'type' => 'event',
'handler' => 'handler_path',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"type" *: *"event"/)
}
end
context 'with optionals' do
let (:params) {{
'type' => 'event',
'handler' => 'handler_path',
'event_name'=> 'eventName',
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"name" *: *"eventName"/)
}
end
end
context '"nodes" type' do
let (:params) {{
'type' => 'nodes',
'handler' => 'handler_path'
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"type" *: *"nodes"/)
}
end
context '"services" type' do
let (:params) {{
'type' => 'services',
'handler' => 'handler_path'
}}
it {
should contain_file('/etc/consul/watch_my_watch.json') \
.with_content(/"type" *: *"services"/)
}
end
context '"unknown_type" type' do
let(:params) {{
'type' => 'unknown_type',
'handler' => 'handler_path',
}}
it {
expect { should raise_error(Puppet::Error)}
}
end
end
end

Просмотреть файл

@ -1,6 +0,0 @@
require 'spec_helper'
describe 'consul_sorted_json' do
it { should run.with_params({'foo' => :undef}).and_return("{}") }
it { should run.with_params({'b' => 1, 'a' => 2, 'c' => 3}).and_return('{"a":2,"b":1,"c":3}')}
end

Просмотреть файл

@ -1,19 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'hiera-puppet-helper/rspec'
require 'hiera'
require 'puppet/indirector/hiera'
# config hiera to work with let(:hiera_data)
def hiera_stub
config = Hiera::Config.load(hiera_config)
config[:logger] = 'puppet'
Hiera.new(:config => config)
end
RSpec.configure do |c|
c.mock_framework = :rspec
c.before(:each) do
Puppet::Indirector::Hiera.stub(:hiera => hiera_stub)
end
end

Просмотреть файл

@ -1,10 +1,17 @@
require 'beaker-rspec'
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
unless ENV['BEAKER_provision'] == 'no'
hosts.each do |host|
# Install Puppet
if host.is_pe?
install_pe
else
install_puppet
end
end
end
#hosts.each do |host|
# # Install Puppet
# install_puppet
#end
#
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
@ -15,10 +22,9 @@ RSpec.configure do |c|
# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(:source => proj_root, :module_name => 'consul')
puppet_module_install(:source => proj_root, :module_name => 'consul_template')
hosts.each do |host|
on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module', 'install', 'nanliu/staging'), { :acceptable_exit_codes => [0,1] }
end
end
end

Просмотреть файл

@ -10,7 +10,7 @@ RSpec.configure do |c|
c.before :suite do
puppet_install
puppet_module_install(:source => proj_root, :module_name => 'consul')
puppet_module_install(:source => proj_root, :module_name => 'consul_template')
shell('puppet module install puppetlabs-stdlib')
end
end

Просмотреть файл

@ -3,7 +3,7 @@ require 'spec_helper_system'
describe 'basic tests' do
it 'class should work without errors' do
pp = <<-EOS
class { 'consul': }
class { 'consul_template': }
EOS
puppet_apply(pp) do |r|

Просмотреть файл

@ -4,8 +4,6 @@ Wants=basic.target
After=basic.target network.target
[Service]
User=<%= scope.lookupvar('consul_template::user') %>
Group=<%= scope.lookupvar('consul_template::group') %>
ExecStart=<%= scope.lookupvar('consul_template::bin_dir') %>/consul-template \
-config <%= scope.lookupvar('consul_template::config_dir') %>/config.json <%= scope.lookupvar('consul_template::extra_options') %>
ExecReload=/bin/kill -HUP $MAINPID

Просмотреть файл

@ -21,7 +21,7 @@ LOG_FILE=/var/log/consul-template
start() {
echo -n "Starting consul-template: "
daemon --user=<%= scope.lookupvar('consul_template::user') %> \
daemon \
--pidfile="$PID_FILE" \
"$CONSUL" -config "$CONFIG"/config.json <%= scope.lookupvar('consul_template::extra_options') %> >> "$LOG_FILE" &
retcode=$?

Просмотреть файл

@ -8,7 +8,7 @@ env CONFIG=<%= scope.lookupvar('consul_template::config_dir') %>
script
exec sudo -u <%= scope.lookupvar('consul_template::user') %> -g <%= scope.lookupvar('consul_template::group') %> $CONSUL -config $CONFIG/config.json <%= scope.lookupvar('consul::extra_options') %>
exec $CONSUL -config $CONFIG/config.json <%= scope.lookupvar('consul::extra_options') %>
end script
respawn

Просмотреть файл

@ -9,4 +9,4 @@
# Learn more about module testing here:
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
include consul
include ::consul_template