Skip to content

Commit 743023a

Browse files
author
Samuli Seppänen
committedDec 16, 2019
Convert with PDK
Signed-off-by: Samuli Seppänen <[email protected]>
1 parent 03eeb16 commit 743023a

18 files changed

+667
-0
lines changed
 

‎.fixtures.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file can be used to install module dependencies for unit testing
2+
# See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details
3+
---
4+
fixtures:
5+
forge_modules:
6+
# stdlib: "puppetlabs/stdlib"

‎.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.rb eol=lf
2+
*.erb eol=lf
3+
*.pp eol=lf
4+
*.sh eol=lf
5+
*.epp eol=lf

‎.gitignore

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.git/
2+
.*.sw[op]
3+
.metadata
4+
.yardoc
5+
.yardwarns
6+
*.iml
7+
/.bundle/
8+
/.idea/
9+
/.vagrant/
10+
/coverage/
11+
/bin/
12+
/doc/
13+
/Gemfile.local
14+
/Gemfile.lock
15+
/junit/
16+
/log/
17+
/pkg/
18+
/spec/fixtures/manifests/
19+
/spec/fixtures/modules/
20+
/tmp/
21+
/vendor/
22+
/convert_report.txt
23+
/update_report.txt
24+
.DS_Store
25+
.project
26+
.envrc
27+
/inventory.yaml

‎.gitlab-ci.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
stages:
3+
- syntax
4+
- unit
5+
6+
cache:
7+
paths:
8+
- vendor/bundle
9+
10+
before_script:
11+
- bundle -v
12+
- rm Gemfile.lock || true
13+
- gem update --system $RUBYGEMS_VERSION
14+
- gem --version
15+
- bundle -v
16+
- bundle install --without system_tests --path vendor/bundle --jobs $(nproc)
17+
18+
syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.3-Puppet ~> 6:
19+
stage: syntax
20+
image: ruby:2.5.3
21+
script:
22+
- bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
23+
variables:
24+
PUPPET_GEM_VERSION: '~> 6'
25+
26+
parallel_spec-Ruby 2.5.3-Puppet ~> 6:
27+
stage: unit
28+
image: ruby:2.5.3
29+
script:
30+
- bundle exec rake parallel_spec
31+
variables:
32+
PUPPET_GEM_VERSION: '~> 6'
33+
34+
parallel_spec-Ruby 2.4.5-Puppet ~> 5:
35+
stage: unit
36+
image: ruby:2.4.5
37+
script:
38+
- bundle exec rake parallel_spec
39+
variables:
40+
PUPPET_GEM_VERSION: '~> 5'
41+

‎.pdkignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.git/
2+
.*.sw[op]
3+
.metadata
4+
.yardoc
5+
.yardwarns
6+
*.iml
7+
/.bundle/
8+
/.idea/
9+
/.vagrant/
10+
/coverage/
11+
/bin/
12+
/doc/
13+
/Gemfile.local
14+
/Gemfile.lock
15+
/junit/
16+
/log/
17+
/pkg/
18+
/spec/fixtures/manifests/
19+
/spec/fixtures/modules/
20+
/tmp/
21+
/vendor/
22+
/convert_report.txt
23+
/update_report.txt
24+
.DS_Store
25+
.project
26+
.envrc
27+
/inventory.yaml
28+
/appveyor.yml
29+
/.fixtures.yml
30+
/Gemfile
31+
/.gitattributes
32+
/.gitignore
33+
/.gitlab-ci.yml
34+
/.pdkignore
35+
/Rakefile
36+
/rakelib/
37+
/.rspec
38+
/.rubocop.yml
39+
/.travis.yml
40+
/.yardopts
41+
/spec/
42+
/.vscode/

‎.puppet-lint.rc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--relative

‎.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format documentation

‎.rubocop.yml

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
require:
3+
- rubocop-rspec
4+
- rubocop-i18n
5+
AllCops:
6+
DisplayCopNames: true
7+
TargetRubyVersion: '2.1'
8+
Include:
9+
- "./**/*.rb"
10+
Exclude:
11+
- bin/*
12+
- ".vendor/**/*"
13+
- "**/Gemfile"
14+
- "**/Rakefile"
15+
- pkg/**/*
16+
- spec/fixtures/**/*
17+
- vendor/**/*
18+
- "**/Puppetfile"
19+
- "**/Vagrantfile"
20+
- "**/Guardfile"
21+
Metrics/LineLength:
22+
Description: People have wide screens, use them.
23+
Max: 200
24+
GetText:
25+
Enabled: false
26+
GetText/DecorateString:
27+
Description: We don't want to decorate test output.
28+
Exclude:
29+
- spec/**/*
30+
Enabled: false
31+
RSpec/BeforeAfterAll:
32+
Description: Beware of using after(:all) as it may cause state to leak between tests.
33+
A necessary evil in acceptance testing.
34+
Exclude:
35+
- spec/acceptance/**/*.rb
36+
RSpec/HookArgument:
37+
Description: Prefer explicit :each argument, matching existing module's style
38+
EnforcedStyle: each
39+
Style/BlockDelimiters:
40+
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
41+
be consistent then.
42+
EnforcedStyle: braces_for_chaining
43+
Style/ClassAndModuleChildren:
44+
Description: Compact style reduces the required amount of indentation.
45+
EnforcedStyle: compact
46+
Style/EmptyElse:
47+
Description: Enforce against empty else clauses, but allow `nil` for clarity.
48+
EnforcedStyle: empty
49+
Style/FormatString:
50+
Description: Following the main puppet project's style, prefer the % format format.
51+
EnforcedStyle: percent
52+
Style/FormatStringToken:
53+
Description: Following the main puppet project's style, prefer the simpler template
54+
tokens over annotated ones.
55+
EnforcedStyle: template
56+
Style/Lambda:
57+
Description: Prefer the keyword for easier discoverability.
58+
EnforcedStyle: literal
59+
Style/RegexpLiteral:
60+
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
61+
EnforcedStyle: percent_r
62+
Style/TernaryParentheses:
63+
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
64+
on complex expressions for better readability, but seriously consider breaking
65+
it up.
66+
EnforcedStyle: require_parentheses_when_complex
67+
Style/TrailingCommaInArguments:
68+
Description: Prefer always trailing comma on multiline argument lists. This makes
69+
diffs, and re-ordering nicer.
70+
EnforcedStyleForMultiline: comma
71+
Style/TrailingCommaInLiteral:
72+
Description: Prefer always trailing comma on multiline literals. This makes diffs,
73+
and re-ordering nicer.
74+
EnforcedStyleForMultiline: comma
75+
Style/SymbolArray:
76+
Description: Using percent style obscures symbolic intent of array's contents.
77+
EnforcedStyle: brackets
78+
RSpec/MessageSpies:
79+
EnforcedStyle: receive
80+
Style/Documentation:
81+
Exclude:
82+
- lib/puppet/parser/functions/**/*
83+
- spec/**/*
84+
Style/WordArray:
85+
EnforcedStyle: brackets
86+
Style/CollectionMethods:
87+
Enabled: true
88+
Style/MethodCalledOnDoEndBlock:
89+
Enabled: true
90+
Style/StringMethods:
91+
Enabled: true
92+
GetText/DecorateFunctionMessage:
93+
Enabled: false
94+
GetText/DecorateStringFormattingUsingInterpolation:
95+
Enabled: false
96+
GetText/DecorateStringFormattingUsingPercent:
97+
Enabled: false
98+
Layout/EndOfLine:
99+
Enabled: false
100+
Layout/IndentHeredoc:
101+
Enabled: false
102+
Metrics/AbcSize:
103+
Enabled: false
104+
Metrics/BlockLength:
105+
Enabled: false
106+
Metrics/ClassLength:
107+
Enabled: false
108+
Metrics/CyclomaticComplexity:
109+
Enabled: false
110+
Metrics/MethodLength:
111+
Enabled: false
112+
Metrics/ModuleLength:
113+
Enabled: false
114+
Metrics/ParameterLists:
115+
Enabled: false
116+
Metrics/PerceivedComplexity:
117+
Enabled: false
118+
RSpec/DescribeClass:
119+
Enabled: false
120+
RSpec/ExampleLength:
121+
Enabled: false
122+
RSpec/MessageExpectation:
123+
Enabled: false
124+
RSpec/MultipleExpectations:
125+
Enabled: false
126+
RSpec/NestedGroups:
127+
Enabled: false
128+
Style/AsciiComments:
129+
Enabled: false
130+
Style/IfUnlessModifier:
131+
Enabled: false
132+
Style/SymbolProc:
133+
Enabled: false

‎.travis.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
dist: xenial
3+
language: ruby
4+
cache: bundler
5+
before_install:
6+
- bundle -v
7+
- rm -f Gemfile.lock
8+
- gem update --system $RUBYGEMS_VERSION
9+
- gem --version
10+
- bundle -v
11+
script:
12+
- 'bundle exec rake $CHECK'
13+
bundler_args: --without system_tests
14+
rvm:
15+
- 2.5.3
16+
stages:
17+
- static
18+
- spec
19+
- acceptance
20+
-
21+
if: tag =~ ^v\d
22+
name: deploy
23+
matrix:
24+
fast_finish: true
25+
include:
26+
-
27+
env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
28+
stage: static
29+
-
30+
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
31+
rvm: 2.4.5
32+
stage: spec
33+
-
34+
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
35+
rvm: 2.5.3
36+
stage: spec
37+
-
38+
env: DEPLOY_TO_FORGE=yes
39+
stage: deploy
40+
branches:
41+
only:
42+
- master
43+
- /^v\d/
44+
notifications:
45+
email: false

‎.vscode/extensions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"jpogran.puppet-vscode",
4+
"rebornix.Ruby"
5+
]
6+
}

‎.yardopts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--markup markdown

‎CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## Release 0.1.0
6+
7+
**Features**
8+
9+
**Bugfixes**
10+
11+
**Known Issues**

‎Gemfile

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2+
3+
def location_for(place_or_version, fake_version = nil)
4+
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
5+
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
6+
7+
if place_or_version && (git_url = place_or_version.match(git_url_regex))
8+
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
9+
elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
10+
['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
11+
else
12+
[place_or_version, { require: false }]
13+
end
14+
end
15+
16+
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
17+
minor_version = ruby_version_segments[0..1].join('.')
18+
19+
group :development do
20+
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
21+
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
22+
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
23+
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
24+
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
25+
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
26+
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
27+
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
28+
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
29+
gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
30+
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
31+
end
32+
33+
puppet_version = ENV['PUPPET_GEM_VERSION']
34+
facter_version = ENV['FACTER_GEM_VERSION']
35+
hiera_version = ENV['HIERA_GEM_VERSION']
36+
37+
gems = {}
38+
39+
gems['puppet'] = location_for(puppet_version)
40+
41+
# If facter or hiera versions have been specified via the environment
42+
# variables
43+
44+
gems['facter'] = location_for(facter_version) if facter_version
45+
gems['hiera'] = location_for(hiera_version) if hiera_version
46+
47+
if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
48+
# If we're using a Puppet gem on Windows which handles its own win32-xxx gem
49+
# dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
50+
gems['win32-dir'] = ['<= 0.4.9', require: false]
51+
gems['win32-eventlog'] = ['<= 0.6.5', require: false]
52+
gems['win32-process'] = ['<= 0.7.5', require: false]
53+
gems['win32-security'] = ['<= 0.2.5', require: false]
54+
gems['win32-service'] = ['0.8.8', require: false]
55+
end
56+
57+
gems.each do |gem_name, gem_params|
58+
gem gem_name, *gem_params
59+
end
60+
61+
# Evaluate Gemfile.local and ~/.gemfile if they exist
62+
extra_gemfiles = [
63+
"#{__FILE__}.local",
64+
File.join(Dir.home, '.gemfile'),
65+
]
66+
67+
extra_gemfiles.each do |gemfile|
68+
if File.file?(gemfile) && File.readable?(gemfile)
69+
eval(File.read(gemfile), binding)
70+
end
71+
end
72+
# vim: syntax=ruby

‎Rakefile

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
2+
require 'puppetlabs_spec_helper/rake_tasks'
3+
require 'puppet-syntax/tasks/puppet-syntax'
4+
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
5+
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
6+
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
7+
8+
def changelog_user
9+
return unless Rake.application.top_level_tasks.include? "changelog"
10+
returnVal = nil || JSON.load(File.read('metadata.json'))['author']
11+
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
12+
puts "GitHubChangelogGenerator user:#{returnVal}"
13+
returnVal
14+
end
15+
16+
def changelog_project
17+
return unless Rake.application.top_level_tasks.include? "changelog"
18+
19+
returnVal = nil
20+
returnVal ||= begin
21+
metadata_source = JSON.load(File.read('metadata.json'))['source']
22+
metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z})
23+
24+
metadata_source_match && metadata_source_match[1]
25+
end
26+
27+
raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil?
28+
29+
puts "GitHubChangelogGenerator project:#{returnVal}"
30+
returnVal
31+
end
32+
33+
def changelog_future_release
34+
return unless Rake.application.top_level_tasks.include? "changelog"
35+
returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
36+
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
37+
puts "GitHubChangelogGenerator future_release:#{returnVal}"
38+
returnVal
39+
end
40+
41+
PuppetLint.configuration.send('disable_relative')
42+
43+
if Bundler.rubygems.find_name('github_changelog_generator').any?
44+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
45+
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
46+
config.user = "#{changelog_user}"
47+
config.project = "#{changelog_project}"
48+
config.future_release = "#{changelog_future_release}"
49+
config.exclude_labels = ['maintenance']
50+
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
51+
config.add_pr_wo_labels = true
52+
config.issues = false
53+
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
54+
config.configure_sections = {
55+
"Changed" => {
56+
"prefix" => "### Changed",
57+
"labels" => ["backwards-incompatible"],
58+
},
59+
"Added" => {
60+
"prefix" => "### Added",
61+
"labels" => ["feature", "enhancement"],
62+
},
63+
"Fixed" => {
64+
"prefix" => "### Fixed",
65+
"labels" => ["bugfix"],
66+
},
67+
}
68+
end
69+
else
70+
desc 'Generate a Changelog from GitHub'
71+
task :changelog do
72+
raise <<EOM
73+
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
74+
Please manually add it to your .sync.yml for now, and run `pdk update`:
75+
---
76+
Gemfile:
77+
optional:
78+
':development':
79+
- gem: 'github_changelog_generator'
80+
git: 'https://github.com/skywinder/github-changelog-generator'
81+
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
82+
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
83+
EOM
84+
end
85+
end
86+

‎appveyor.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
version: 1.1.x.{build}
3+
branches:
4+
only:
5+
- master
6+
- release
7+
skip_commits:
8+
message: /^\(?doc\)?.*/
9+
clone_depth: 10
10+
init:
11+
- SET
12+
- 'mkdir C:\ProgramData\PuppetLabs\code && exit 0'
13+
- 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0'
14+
- 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0'
15+
- 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0'
16+
environment:
17+
matrix:
18+
-
19+
RUBY_VERSION: 24-x64
20+
CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
21+
-
22+
PUPPET_GEM_VERSION: ~> 5.0
23+
RUBY_VERSION: 24
24+
CHECK: parallel_spec
25+
-
26+
PUPPET_GEM_VERSION: ~> 5.0
27+
RUBY_VERSION: 24-x64
28+
CHECK: parallel_spec
29+
-
30+
PUPPET_GEM_VERSION: ~> 6.0
31+
RUBY_VERSION: 25
32+
CHECK: parallel_spec
33+
-
34+
PUPPET_GEM_VERSION: ~> 6.0
35+
RUBY_VERSION: 25-x64
36+
CHECK: parallel_spec
37+
matrix:
38+
fast_finish: true
39+
install:
40+
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
41+
- bundle install --jobs 4 --retry 2 --without system_tests
42+
- type Gemfile.lock
43+
build: off
44+
test_script:
45+
- bundle exec puppet -V
46+
- ruby -v
47+
- gem -v
48+
- bundle -v
49+
- bundle exec rake %CHECK%
50+
notifications:
51+
- provider: Email
52+
to:
53+
- nobody@nowhere.com
54+
on_build_success: false
55+
on_build_failure: false
56+
on_build_status_changed: false

‎metadata.json

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"name": "puppetfinland-resolver",
3+
"version": "0.1.0",
4+
"author": "Puppet-Finland team",
5+
"summary": "",
6+
"license": "BSD-2-Clause",
7+
"source": "",
8+
"dependencies": [
9+
10+
],
11+
"operatingsystem_support": [
12+
{
13+
"operatingsystem": "CentOS",
14+
"operatingsystemrelease": [
15+
"7"
16+
]
17+
},
18+
{
19+
"operatingsystem": "OracleLinux",
20+
"operatingsystemrelease": [
21+
"7"
22+
]
23+
},
24+
{
25+
"operatingsystem": "RedHat",
26+
"operatingsystemrelease": [
27+
"8"
28+
]
29+
},
30+
{
31+
"operatingsystem": "Scientific",
32+
"operatingsystemrelease": [
33+
"7"
34+
]
35+
},
36+
{
37+
"operatingsystem": "Debian",
38+
"operatingsystemrelease": [
39+
"9"
40+
]
41+
},
42+
{
43+
"operatingsystem": "Ubuntu",
44+
"operatingsystemrelease": [
45+
"18.04"
46+
]
47+
},
48+
{
49+
"operatingsystem": "windows",
50+
"operatingsystemrelease": [
51+
"2019",
52+
"10"
53+
]
54+
},
55+
{
56+
"operatingsystem": "Fedora",
57+
"operatingsystemrelease": [
58+
"29"
59+
]
60+
}
61+
],
62+
"requirements": [
63+
{
64+
"name": "puppet",
65+
"version_requirement": ">= 4.10.0 < 7.0.0"
66+
}
67+
],
68+
"pdk-version": "1.14.1",
69+
"template-url": "pdk-default#1.14.1",
70+
"template-ref": "1.14.1-0-g0b5b39b"
71+
}

‎spec/default_facts.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Use default_module_facts.yml for module specific facts.
2+
#
3+
# Facts specified here will override the values provided by rspec-puppet-facts.
4+
---
5+
ipaddress: "172.16.254.254"
6+
ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA"
7+
is_pe: false
8+
macaddress: "AA:AA:AA:AA:AA:AA"

‎spec/spec_helper.rb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
require 'puppetlabs_spec_helper/module_spec_helper'
2+
require 'rspec-puppet-facts'
3+
4+
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
5+
6+
include RspecPuppetFacts
7+
8+
default_facts = {
9+
puppetversion: Puppet.version,
10+
facterversion: Facter.version,
11+
}
12+
13+
default_fact_files = [
14+
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
15+
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
16+
]
17+
18+
default_fact_files.each do |f|
19+
next unless File.exist?(f) && File.readable?(f) && File.size?(f)
20+
21+
begin
22+
default_facts.merge!(YAML.safe_load(File.read(f), [], [], true))
23+
rescue => e
24+
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
25+
end
26+
end
27+
28+
# read default_facts and merge them over what is provided by facterdb
29+
default_facts.each do |fact, value|
30+
add_custom_fact fact, value
31+
end
32+
33+
RSpec.configure do |c|
34+
c.default_facts = default_facts
35+
c.before :each do
36+
# set to strictest setting for testing
37+
# by default Puppet runs at warning level
38+
Puppet.settings[:strict] = :warning
39+
end
40+
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
41+
c.after(:suite) do
42+
end
43+
end
44+
45+
# Ensures that a module is defined
46+
# @param module_name Name of the module
47+
def ensure_module_defined(module_name)
48+
module_name.split('::').reduce(Object) do |last_module, next_module|
49+
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
50+
last_module.const_get(next_module, false)
51+
end
52+
end
53+
54+
# 'spec_overrides' from sync.yml will appear below this line

0 commit comments

Comments
 (0)
Please sign in to comment.