Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Commit 83d58d2

Browse files
committed
Support Puppet v4 AIO
This adds support for running under Puppet v4 with Ruby v2.3.1 and explicitly tests supported versions.
1 parent b8778e1 commit 83d58d2

File tree

12 files changed

+163
-79
lines changed

12 files changed

+163
-79
lines changed

.fixtures.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
fixtures:
22
repositories:
3-
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
3+
stdlib:
4+
repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
5+
ref: '4.6.0'
46
symlinks:
5-
"ruby": "#{source_dir}"
7+
ruby: "#{source_dir}"

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
*.sw*
2-
31
# Default .gitignore for Ruby
42
*.gem
53
*.rbc
@@ -23,6 +21,9 @@ doc/
2321
# Vim
2422
*.swp
2523

24+
# Eclipse
25+
.project
26+
2627
# OS X
2728
.DS_Store
2829

.travis.yml

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,75 @@
11
---
2-
sudo: true
32
language: ruby
4-
bundler_args: --without development system_tests
5-
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
3+
4+
rvm:
5+
- 1.9.3
6+
- 2.0.0
7+
- 2.1.9
8+
- 2.3.1
9+
10+
env:
11+
matrix:
12+
- PUPPET_GEM_VERSION="~> 3.1.0"
13+
- PUPPET_GEM_VERSION="~> 3.2.0"
14+
- PUPPET_GEM_VERSION="~> 3.3.0"
15+
- PUPPET_GEM_VERSION="~> 3.4.0"
16+
- PUPPET_GEM_VERSION="~> 3.5.0"
17+
- PUPPET_GEM_VERSION="~> 3.6.0"
18+
- PUPPET_GEM_VERSION="~> 3.7.0"
19+
- PUPPET_GEM_VERSION="~> 3.8.0"
20+
- PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
21+
- PUPPET_GEM_VERSION="~> 4.0.0"
22+
- PUPPET_GEM_VERSION="~> 4.1.0"
23+
- PUPPET_GEM_VERSION="~> 4.2.0"
24+
- PUPPET_GEM_VERSION="~> 4.3.0"
25+
- PUPPET_GEM_VERSION="~> 4.4.0"
26+
- PUPPET_GEM_VERSION="~> 4.5.0"
27+
- PUPPET_GEM_VERSION="~> 4.6.0"
28+
- PUPPET_GEM_VERSION="~> 4.7.0"
29+
- PUPPET_GEM_VERSION="~> 4.8.0"
30+
- PUPPET_GEM_VERSION="~> 4"
31+
32+
sudo: false
33+
34+
bundler_args: '--without development system_tests'
35+
36+
before_install:
37+
- 'gem update --system'
38+
- 'gem update bundler'
39+
40+
script: 'SPEC_OPTS="--format documentation" bundle exec rake validate lint spec'
41+
642
matrix:
743
fast_finish: true
8-
include:
9-
- rvm: 1.9.3
10-
env: PUPPET_GEM_VERSION="~> 3.0"
11-
- rvm: 2.1.8
12-
env: PUPPET_GEM_VERSION="~> 3.0"
44+
exclude:
45+
- rvm: 2.0.0
46+
env: PUPPET_GEM_VERSION="~> 3.1.0"
47+
- rvm: 2.1.9
48+
env: PUPPET_GEM_VERSION="~> 3.1.0"
49+
- rvm: 2.1.9
50+
env: PUPPET_GEM_VERSION="~> 3.2.0"
51+
- rvm: 2.1.9
52+
env: PUPPET_GEM_VERSION="~> 3.3.0"
53+
- rvm: 2.1.9
54+
env: PUPPET_GEM_VERSION="~> 3.4.0"
55+
- rvm: 2.3.1
56+
env: PUPPET_GEM_VERSION="~> 3.1.0"
57+
- rvm: 2.3.1
58+
env: PUPPET_GEM_VERSION="~> 3.2.0"
59+
- rvm: 2.3.1
60+
env: PUPPET_GEM_VERSION="~> 3.3.0"
61+
- rvm: 2.3.1
62+
env: PUPPET_GEM_VERSION="~> 3.4.0"
63+
- rvm: 2.3.1
64+
env: PUPPET_GEM_VERSION="~> 3.5.0"
65+
- rvm: 2.3.1
66+
env: PUPPET_GEM_VERSION="~> 3.6.0"
67+
- rvm: 2.3.1
68+
env: PUPPET_GEM_VERSION="~> 3.7.0"
69+
- rvm: 2.3.1
70+
env: PUPPET_GEM_VERSION="~> 3.8.0"
71+
- rvm: 2.3.1
72+
env: PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
73+
1374
notifications:
1475
email: false

Gemfile

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,34 @@
1-
source ENV['GEM_SOURCE'] || "https://rubygems.org"
2-
3-
def location_for(place, fake_version = nil)
4-
if place =~ /^(git:[^#]*)#(.*)/
5-
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
6-
elsif place =~ /^file:\/\/(.*)/
7-
['>= 0', { :path => File.expand_path($1), :require => false }]
8-
else
9-
[place, { :require => false }]
10-
end
11-
end
12-
13-
if facterversion = ENV['FACTER_GEM_VERSION']
14-
gem 'facter', facterversion, :require => false
15-
else
16-
gem 'facter', :require => false
17-
end
1+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
182

193
if puppetversion = ENV['PUPPET_GEM_VERSION']
204
gem 'puppet', puppetversion, :require => false
215
else
226
gem 'puppet', :require => false
237
end
248

25-
gem 'metadata-json-lint'
26-
gem 'puppetlabs_spec_helper', '>= 1.2.0'
27-
gem 'simplecov'
28-
gem 'puppet_facts'
29-
gem 'rspec-puppet'
30-
gem 'puppet-lint', '~> 2.0'
31-
gem 'puppet-lint-alias-check'
32-
gem 'puppet-lint-empty_string-check'
33-
gem 'puppet-lint-file_ensure-check'
34-
gem 'puppet-lint-file_source_rights-check'
35-
gem 'puppet-lint-leading_zero-check'
36-
gem 'puppet-lint-spaceship_operator_without_tag-check'
37-
gem 'puppet-lint-trailing_comma-check'
38-
gem 'puppet-lint-unquoted_string-check'
39-
gem 'puppet-lint-variable_contains_upcase'
9+
gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
10+
gem 'facter', '>= 1.7.0', :require => false
11+
gem 'rspec-puppet', :require => false
12+
gem 'puppet-lint', '~> 2.0', :require => false
13+
gem 'puppet-lint-absolute_classname-check', :require => false
14+
gem 'puppet-lint-alias-check', :require => false
15+
gem 'puppet-lint-empty_string-check', :require => false
16+
gem 'puppet-lint-file_ensure-check', :require => false
17+
gem 'puppet-lint-file_source_rights-check', :require => false
18+
gem 'puppet-lint-leading_zero-check', :require => false
19+
gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false
20+
gem 'puppet-lint-trailing_comma-check', :require => false
21+
gem 'puppet-lint-undef_in_function-check', :require => false
22+
gem 'puppet-lint-unquoted_string-check', :require => false
23+
gem 'puppet-lint-variable_contains_upcase', :require => false
4024

41-
gem 'rspec', '~> 2.0' if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
42-
gem 'rake', '~> 10.0' if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
43-
gem 'json', '<= 1.8' if RUBY_VERSION < '2.0.0'
44-
gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0'
25+
gem 'rspec','~> 2.0', :require => false if RUBY_VERSION < '1.9'
26+
gem 'rake', '~> 10.0', :require => false if RUBY_VERSION < '1.9'
27+
gem 'json', '<= 1.8', :require => false if RUBY_VERSION < '2.0.0'
28+
gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0'
29+
gem 'json', :require => false if RUBY_VERSION >= '2.0.0'
30+
gem 'metadata-json-lint', '0.0.11', :require => false if RUBY_VERSION < '1.9'
31+
gem 'metadata-json-lint', :require => false if RUBY_VERSION >= '1.9'
4532

4633
group :system_tests do
4734
if beaker_version = ENV['BEAKER_VERSION']
@@ -50,9 +37,9 @@ group :system_tests do
5037
if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
5138
gem 'beaker-rspec', *location_for(beaker_rspec_version)
5239
else
53-
gem 'beaker-rspec', :require => false
40+
gem 'beaker-rspec', :require => false
5441
end
55-
gem 'serverspec', :require => false
42+
gem 'serverspec', :require => false
5643
gem 'beaker-puppet_install_helper', :require => false
5744
end
5845

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2012 Puppet Labs Inc
1+
Copyright (C) 2012-2016 Puppet Labs Inc
22

33
Puppet Labs can be contacted at: [email protected]
44

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This module manages Ruby and Rubygems.
44

55
# Compatibility
6-
Puppet v3 with Ruby 1.9.3 and 2.1.8 on the following platforms.
6+
Puppet v3 with Ruby 1.9.3, 2.0.0, 2.1.9 and 2.3.1 on the following platforms.
77

88
* Debian 6
99
* Debian 7

Rakefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
require 'puppetlabs_spec_helper/rake_tasks'
22
require 'puppet-lint/tasks/puppet-lint'
3-
4-
PuppetLint.configuration.fail_on_warnings = true
5-
PuppetLint.configuration.send('relative')
63
PuppetLint.configuration.send('disable_80chars')
74
PuppetLint.configuration.send('disable_140chars')
8-
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
9-
PuppetLint.configuration.send('disable_documentation')
10-
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
5+
PuppetLint.configuration.relative = true
116
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
7+
8+
desc 'Validate manifests, templates, and ruby files'
9+
task :validate do
10+
Dir['manifests/**/*.pp'].each do |manifest|
11+
sh "puppet parser validate --noop #{manifest}"
12+
end
13+
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
14+
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
15+
end
16+
Dir['templates/**/*.erb'].each do |template|
17+
sh "erb -P -x -T '-' #{template} | ruby -c"
18+
end
19+
end

manifests/bundle.pp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
(
5353
$command = 'install',
5454
$option = undef,
55-
$rails_env = $ruby::params::rails_env,
55+
$rails_env = undef,
5656
$multicore = undef,
5757
$creates = undef,
5858
$cwd = undef,
@@ -72,6 +72,12 @@
7272

7373
require ::ruby
7474

75+
if $rails_env == undef {
76+
$rails_env_real = $ruby::params::rails_env
77+
} else {
78+
$rails_env_real = $rails_env
79+
}
80+
7581
# ensure minimum path requirements for bundler
7682
if $path {
7783
$real_path = unique(flatten([$path, $ruby::params::minimum_path]))
@@ -81,9 +87,9 @@
8187

8288
# merge the environment and rails_env parameters
8389
if $environment {
84-
$real_environment = unique(flatten([$environment, ["RAILS_ENV=${rails_env}"]]))
90+
$real_environment = unique(flatten([$environment, ["RAILS_ENV=${rails_env_real}"]]))
8591
} else {
86-
$real_environment = "RAILS_ENV=${rails_env}"
92+
$real_environment = "RAILS_ENV=${rails_env_real}"
8793
}
8894

8995
if $multicore {
@@ -93,7 +99,7 @@
9399
$multicore_str = " --jobs ${multicore}"
94100
}
95101
} else {
96-
$multicore_str = ''
102+
$multicore_str = undef
97103
}
98104

99105
case $command {
@@ -162,5 +168,4 @@
162168
unless => $real_unless,
163169
require => Package['bundler'],
164170
}
165-
166171
}

manifests/rake.pp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
define ruby::rake
6464
(
6565
$task,
66-
$rails_env = $ruby::params::rails_env,
66+
$rails_env = undef,
6767
$bundle = false,
6868
$creates = undef,
6969
$cwd = undef,
@@ -83,6 +83,12 @@
8383

8484
require ::ruby
8585

86+
if $rails_env == undef {
87+
$rails_env_real = $ruby::params::rails_env
88+
} else {
89+
$rails_env_real = $rails_env
90+
}
91+
8692
# Hmm this works on http://rubular.com/
8793
# validate_re($task, '^[a-z][a-z0-9]*((:[a-z][a-z0-9]*)?)*$', "The rake task '${task}' does not conform to an expected format.")
8894

@@ -95,9 +101,9 @@
95101

96102
# merge the environment and rails_env parameters
97103
if $environment {
98-
$real_environment = unique(flatten([$environment, ["RAILS_ENV=${rails_env}"]]))
104+
$real_environment = unique(flatten([$environment, ["RAILS_ENV=${rails_env_real}"]]))
99105
} else {
100-
$real_environment = "RAILS_ENV=${rails_env}"
106+
$real_environment = "RAILS_ENV=${rails_env_real}"
101107
}
102108

103109
$real_command = join(['rake', $task],' ')
@@ -108,7 +114,7 @@
108114
ruby::bundle{"ruby_rake_${name}":
109115
command => 'exec',
110116
option => $real_command,
111-
rails_env => $rails_env,
117+
rails_env => $rails_env_real,
112118
creates => $creates,
113119
cwd => $cwd,
114120
environment => $environment,
@@ -145,5 +151,4 @@
145151
require => Package['rake'],
146152
}
147153
}
148-
149154
}

metadata.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,16 @@
6969
}
7070
],
7171
"requirements": [
72+
{
73+
"name": "pe",
74+
"version_requirement": ">= 3.2.0 < 5.0.0"
75+
},
7276
{
7377
"name": "puppet",
74-
"version_requirement": "3.x"
78+
"version_requirement": ">= 3.0.0 < 5.0.0"
7579
}
7680
],
7781
"dependencies": [
78-
{"name":"puppetlabs/stdlib","version_requirement":">=3.2.0 <5.0.0"}
82+
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"}
7983
]
8084
}

0 commit comments

Comments
 (0)