aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppet.com>2018-07-09 17:05:53 -0700
committerJosh Cooper <josh@puppet.com>2018-07-09 17:05:53 -0700
commit1c6ae8bfde5175c5d3512f5acb5352fda94a4801 (patch)
tree43d077f7a23f82639709bcb43d81c2e31139fb1c
parent9d96ddecea6367abee1aa77859848b0c158fca80 (diff)
downloadpuppet-hosts_core-1c6ae8bfde5175c5d3512f5acb5352fda94a4801.tar.gz
puppet-hosts_core-1c6ae8bfde5175c5d3512f5acb5352fda94a4801.tar.bz2
Initial pdk new module
-rw-r--r--.fixtures.yml6
-rw-r--r--.gitattributes4
-rw-r--r--.gitignore24
-rw-r--r--.gitlab-ci.yml41
-rw-r--r--.pdkignore24
-rw-r--r--.rspec2
-rw-r--r--.rubocop.yml116
-rw-r--r--.travis.yml44
-rw-r--r--.yardopts1
-rw-r--r--CHANGELOG.md11
-rw-r--r--Gemfile78
-rw-r--r--README.md97
-rw-r--r--Rakefile6
-rw-r--r--appveyor.yml52
-rw-r--r--metadata.json90
-rw-r--r--spec/default_facts.yml8
-rw-r--r--spec/spec_helper.rb45
17 files changed, 647 insertions, 2 deletions
diff --git a/.fixtures.yml b/.fixtures.yml
new file mode 100644
index 0000000..2296adb
--- /dev/null
+++ b/.fixtures.yml
@@ -0,0 +1,6 @@
+# This file can be used to install module dependencies for unit testing
+# See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details
+---
+fixtures:
+ forge_modules:
+# stdlib: "puppetlabs/stdlib"
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..543dd6a
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+*.rb eol=lf
+*.erb eol=lf
+*.pp eol=lf
+*.sh eol=lf
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..650022e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,24 @@
+.git/
+.*.sw[op]
+.metadata
+.yardoc
+.yardwarns
+*.iml
+/.bundle/
+/.idea/
+/.vagrant/
+/coverage/
+/bin/
+/doc/
+/Gemfile.local
+/Gemfile.lock
+/junit/
+/log/
+/pkg/
+/spec/fixtures/manifests/
+/spec/fixtures/modules/
+/tmp/
+/vendor/
+/convert_report.txt
+/update_report.txt
+.DS_Store
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..d651650
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,41 @@
+---
+stages:
+ - syntax
+ - unit
+
+cache:
+ paths:
+ - vendor/bundle
+
+before_script:
+ - bundle -v
+ - rm Gemfile.lock || true
+ - gem update --system
+ - gem --version
+ - bundle -v
+ - bundle install --without system_tests --path vendor/bundle --jobs $(nproc)
+
+parallel_spec-Ruby 2.1.9-Puppet ~> 4.0:
+ stage: syntax
+ image: ruby:2.1.9
+ script:
+ - bundle exec rake parallel_spec
+ variables:
+ PUPPET_GEM_VERSION: '~> 4.0'
+
+syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.4.4-Puppet ~> 5.5:
+ stage: syntax
+ image: ruby:2.4.4
+ script:
+ - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
+ variables:
+ PUPPET_GEM_VERSION: '~> 5.5'
+
+parallel_spec-Ruby 2.4.4-Puppet ~> 5.5:
+ stage: syntax
+ image: ruby:2.4.4
+ script:
+ - bundle exec rake parallel_spec
+ variables:
+ PUPPET_GEM_VERSION: '~> 5.5'
+
diff --git a/.pdkignore b/.pdkignore
new file mode 100644
index 0000000..650022e
--- /dev/null
+++ b/.pdkignore
@@ -0,0 +1,24 @@
+.git/
+.*.sw[op]
+.metadata
+.yardoc
+.yardwarns
+*.iml
+/.bundle/
+/.idea/
+/.vagrant/
+/coverage/
+/bin/
+/doc/
+/Gemfile.local
+/Gemfile.lock
+/junit/
+/log/
+/pkg/
+/spec/fixtures/manifests/
+/spec/fixtures/modules/
+/tmp/
+/vendor/
+/convert_report.txt
+/update_report.txt
+.DS_Store
diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..16f9cdb
--- /dev/null
+++ b/.rspec
@@ -0,0 +1,2 @@
+--color
+--format documentation
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..faa6470
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,116 @@
+---
+require: rubocop-rspec
+AllCops:
+ DisplayCopNames: true
+ TargetRubyVersion: '2.1'
+ Include:
+ - "./**/*.rb"
+ Exclude:
+ - bin/*
+ - ".vendor/**/*"
+ - "**/Gemfile"
+ - "**/Rakefile"
+ - pkg/**/*
+ - spec/fixtures/**/*
+ - vendor/**/*
+ - "**/Puppetfile"
+ - "**/Vagrantfile"
+ - "**/Guardfile"
+Metrics/LineLength:
+ Description: People have wide screens, use them.
+ Max: 200
+RSpec/BeforeAfterAll:
+ Description: Beware of using after(:all) as it may cause state to leak between tests.
+ A necessary evil in acceptance testing.
+ Exclude:
+ - spec/acceptance/**/*.rb
+RSpec/HookArgument:
+ Description: Prefer explicit :each argument, matching existing module's style
+ EnforcedStyle: each
+Style/BlockDelimiters:
+ Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
+ be consistent then.
+ EnforcedStyle: braces_for_chaining
+Style/ClassAndModuleChildren:
+ Description: Compact style reduces the required amount of indentation.
+ EnforcedStyle: compact
+Style/EmptyElse:
+ Description: Enforce against empty else clauses, but allow `nil` for clarity.
+ EnforcedStyle: empty
+Style/FormatString:
+ Description: Following the main puppet project's style, prefer the % format format.
+ EnforcedStyle: percent
+Style/FormatStringToken:
+ Description: Following the main puppet project's style, prefer the simpler template
+ tokens over annotated ones.
+ EnforcedStyle: template
+Style/Lambda:
+ Description: Prefer the keyword for easier discoverability.
+ EnforcedStyle: literal
+Style/RegexpLiteral:
+ Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
+ EnforcedStyle: percent_r
+Style/TernaryParentheses:
+ Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
+ on complex expressions for better readability, but seriously consider breaking
+ it up.
+ EnforcedStyle: require_parentheses_when_complex
+Style/TrailingCommaInArguments:
+ Description: Prefer always trailing comma on multiline argument lists. This makes
+ diffs, and re-ordering nicer.
+ EnforcedStyleForMultiline: comma
+Style/TrailingCommaInLiteral:
+ Description: Prefer always trailing comma on multiline literals. This makes diffs,
+ and re-ordering nicer.
+ EnforcedStyleForMultiline: comma
+Style/SymbolArray:
+ Description: Using percent style obscures symbolic intent of array's contents.
+ EnforcedStyle: brackets
+RSpec/MessageSpies:
+ EnforcedStyle: receive
+Style/Documentation:
+ Exclude:
+ - lib/puppet/parser/functions/**/*
+ - spec/**/*
+Style/WordArray:
+ EnforcedStyle: brackets
+Style/CollectionMethods:
+ Enabled: true
+Style/MethodCalledOnDoEndBlock:
+ Enabled: true
+Style/StringMethods:
+ Enabled: true
+Layout/EndOfLine:
+ Enabled: false
+Metrics/AbcSize:
+ Enabled: false
+Metrics/BlockLength:
+ Enabled: false
+Metrics/ClassLength:
+ Enabled: false
+Metrics/CyclomaticComplexity:
+ Enabled: false
+Metrics/MethodLength:
+ Enabled: false
+Metrics/ModuleLength:
+ Enabled: false
+Metrics/ParameterLists:
+ Enabled: false
+Metrics/PerceivedComplexity:
+ Enabled: false
+RSpec/DescribeClass:
+ Enabled: false
+RSpec/ExampleLength:
+ Enabled: false
+RSpec/MessageExpectation:
+ Enabled: false
+RSpec/MultipleExpectations:
+ Enabled: false
+RSpec/NestedGroups:
+ Enabled: false
+Style/AsciiComments:
+ Enabled: false
+Style/IfUnlessModifier:
+ Enabled: false
+Style/SymbolProc:
+ Enabled: false
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..81f77dd
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,44 @@
+---
+sudo: false
+dist: trusty
+language: ruby
+cache: bundler
+before_install:
+ - bundle -v
+ - rm -f Gemfile.lock
+ - gem update --system
+ - gem --version
+ - bundle -v
+script:
+ - 'bundle exec rake $CHECK'
+bundler_args: --without system_tests
+rvm:
+ - 2.4.1
+env:
+ global:
+ - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
+matrix:
+ fast_finish: true
+ include:
+ -
+ env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
+ -
+ env: CHECK=parallel_spec
+ -
+ env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
+ rvm: 2.1.9
+branches:
+ only:
+ - master
+ - /^v\d/
+notifications:
+ email: false
+deploy:
+ provider: puppetforge
+ user: puppet
+ password:
+ secure: ""
+ on:
+ tags: true
+ all_branches: true
+ condition: "$DEPLOY_TO_FORGE = yes"
diff --git a/.yardopts b/.yardopts
new file mode 100644
index 0000000..29c933b
--- /dev/null
+++ b/.yardopts
@@ -0,0 +1 @@
+--markup markdown
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..4c954cd
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,11 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+## Release 0.1.0
+
+**Features**
+
+**Bugfixes**
+
+**Known Issues**
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..5cda86e
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,78 @@
+source ENV['GEM_SOURCE'] || 'https://rubygems.org'
+
+def location_for(place_or_version, fake_version = nil)
+ if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)}
+ [fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
+ elsif place_or_version =~ %r{\Afile:\/\/(.*)}
+ ['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
+ else
+ [place_or_version, { require: false }]
+ end
+end
+
+def gem_type(place_or_version)
+ if place_or_version =~ %r{\Agit[:@]}
+ :git
+ elsif !place_or_version.nil? && place_or_version.start_with?('file:')
+ :file
+ else
+ :gem
+ end
+end
+
+ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
+minor_version = ruby_version_segments[0..1].join('.')
+
+group :development do
+ gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
+ gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
+ gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
+ gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
+ gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
+ gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
+ gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
+ gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
+ gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
+end
+
+puppet_version = ENV['PUPPET_GEM_VERSION']
+puppet_type = gem_type(puppet_version)
+facter_version = ENV['FACTER_GEM_VERSION']
+hiera_version = ENV['HIERA_GEM_VERSION']
+
+gems = {}
+
+gems['puppet'] = location_for(puppet_version)
+
+# If facter or hiera versions have been specified via the environment
+# variables
+
+gems['facter'] = location_for(facter_version) if facter_version
+gems['hiera'] = location_for(hiera_version) if hiera_version
+
+if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
+ # If we're using a Puppet gem on Windows which handles its own win32-xxx gem
+ # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
+ gems['win32-dir'] = ['<= 0.4.9', require: false]
+ gems['win32-eventlog'] = ['<= 0.6.5', require: false]
+ gems['win32-process'] = ['<= 0.7.5', require: false]
+ gems['win32-security'] = ['<= 0.2.5', require: false]
+ gems['win32-service'] = ['0.8.8', require: false]
+end
+
+gems.each do |gem_name, gem_params|
+ gem gem_name, *gem_params
+end
+
+# Evaluate Gemfile.local and ~/.gemfile if they exist
+extra_gemfiles = [
+ "#{__FILE__}.local",
+ File.join(Dir.home, '.gemfile'),
+]
+
+extra_gemfiles.each do |gemfile|
+ if File.file?(gemfile) && File.readable?(gemfile)
+ eval(File.read(gemfile), binding)
+ end
+end
+# vim: syntax=ruby
diff --git a/README.md b/README.md
index f3b459f..2409942 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,95 @@
-# puppetlabs-host_core
-Install and manage host entries
+
+# host_core
+
+Welcome to your new module. A short overview of the generated parts can be found in the PDK documentation at https://puppet.com/pdk/latest/pdk_generating_modules.html .
+
+The README template below provides a starting point with details about what information to include in your README.
+
+
+
+
+
+
+
+#### Table of Contents
+
+1. [Description](#description)
+2. [Setup - The basics of getting started with host_core](#setup)
+ * [What host_core affects](#what-host_core-affects)
+ * [Setup requirements](#setup-requirements)
+ * [Beginning with host_core](#beginning-with-host_core)
+3. [Usage - Configuration options and additional functionality](#usage)
+4. [Limitations - OS compatibility, etc.](#limitations)
+5. [Development - Guide for contributing to the module](#development)
+
+## Description
+
+Briefly tell users why they might want to use your module. Explain what your module does and what kind of problems users can solve with it.
+
+This should be a fairly short description helps the user decide if your module is what they want.
+
+
+## Setup
+
+### What host_core affects **OPTIONAL**
+
+If it's obvious what your module touches, you can skip this section. For example, folks can probably figure out that your mysql_instance module affects their MySQL instances.
+
+If there's more that they should know about, though, this is the place to mention:
+
+* Files, packages, services, or operations that the module will alter, impact, or execute.
+* Dependencies that your module automatically installs.
+* Warnings or other important notices.
+
+### Setup Requirements **OPTIONAL**
+
+If your module requires anything extra before setting up (pluginsync enabled, another module, etc.), mention it here.
+
+If your most recent release breaks compatibility or requires particular steps for upgrading, you might want to include an additional "Upgrading" section here.
+
+### Beginning with host_core
+
+The very basic steps needed for a user to get the module up and running. This can include setup steps, if necessary, or it can be an example of the most basic use of the module.
+
+## Usage
+
+Include usage examples for common use cases in the **Usage** section. Show your users how to use your module to solve problems, and be sure to include code examples. Include three to five examples of the most important or common tasks a user can accomplish with your module. Show users how to accomplish more complex tasks that involve different types, classes, and functions working in tandem.
+
+## Reference
+
+This section is deprecated. Instead, add reference information to your code as Puppet Strings comments, and then use Strings to generate a REFERENCE.md in your module. For details on how to add code comments and generate documentation with Strings, see the Puppet Strings [documentation](https://puppet.com/docs/puppet/latest/puppet_strings.html) and [style guide](https://puppet.com/docs/puppet/latest/puppet_strings_style.html)
+
+If you aren't ready to use Strings yet, manually create a REFERENCE.md in the root of your module directory and list out each of your module's classes, defined types, facts, functions, Puppet tasks, task plans, and resource types and providers, along with the parameters for each.
+
+For each element (class, defined type, function, and so on), list:
+
+ * The data type, if applicable.
+ * A description of what the element does.
+ * Valid values, if the data type doesn't make it obvious.
+ * Default value, if any.
+
+For example:
+
+```
+### `pet::cat`
+
+#### Parameters
+
+##### `meow`
+
+Enables vocalization in your cat. Valid options: 'string'.
+
+Default: 'medium-loud'.
+```
+
+## Limitations
+
+In the Limitations section, list any incompatibilities, known issues, or other warnings.
+
+## Development
+
+In the Development section, tell other users the ground rules for contributing to your project and how they should submit their work.
+
+## Release Notes/Contributors/Etc. **Optional**
+
+If you aren't using changelog, put your release notes here (though you should consider using changelog). You can also add any additional sections you feel are necessary or important to include here. Please use the `## ` header.
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..d4e36da
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,6 @@
+require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-syntax/tasks/puppet-syntax'
+require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
+
+PuppetLint.configuration.send('disable_relative')
+
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..4a5b227
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,52 @@
+---
+version: 1.1.x.{build}
+skip_commits:
+ message: /^\(?doc\)?.*/
+clone_depth: 10
+init:
+ - SET
+ - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0'
+ - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0'
+ - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0'
+ - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0'
+environment:
+ matrix:
+ -
+ RUBY_VERSION: 24-x64
+ CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
+ -
+ PUPPET_GEM_VERSION: ~> 4.0
+ RUBY_VERSION: 21
+ CHECK: parallel_spec
+ -
+ PUPPET_GEM_VERSION: ~> 4.0
+ RUBY_VERSION: 21-x64
+ CHECK: parallel_spec
+ -
+ PUPPET_GEM_VERSION: ~> 5.0
+ RUBY_VERSION: 24
+ CHECK: parallel_spec
+ -
+ PUPPET_GEM_VERSION: ~> 5.0
+ RUBY_VERSION: 24-x64
+ CHECK: parallel_spec
+matrix:
+ fast_finish: true
+install:
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
+ - bundle install --jobs 4 --retry 2 --without system_tests
+ - type Gemfile.lock
+build: off
+test_script:
+ - bundle exec puppet -V
+ - ruby -v
+ - gem -v
+ - bundle -v
+ - bundle exec rake %CHECK%
+notifications:
+ - provider: Email
+ to:
+ - nobody@nowhere.com
+ on_build_success: false
+ on_build_failure: false
+ on_build_status_changed: false
diff --git a/metadata.json b/metadata.json
new file mode 100644
index 0000000..6bee2f3
--- /dev/null
+++ b/metadata.json
@@ -0,0 +1,90 @@
+{
+ "name": "puppetlabs-host_core",
+ "version": "0.1.0",
+ "author": "Puppet Labs",
+ "summary": "",
+ "license": "Apache-2.0",
+ "source": "",
+ "dependencies": [
+
+ ],
+ "operatingsystem_support": [
+ {
+ "operatingsystem": "CentOS",
+ "operatingsystemrelease": [
+ "7"
+ ]
+ },
+ {
+ "operatingsystem": "OracleLinux",
+ "operatingsystemrelease": [
+ "7"
+ ]
+ },
+ {
+ "operatingsystem": "RedHat",
+ "operatingsystemrelease": [
+ "7"
+ ]
+ },
+ {
+ "operatingsystem": "Scientific",
+ "operatingsystemrelease": [
+ "7"
+ ]
+ },
+ {
+ "operatingsystem": "Debian",
+ "operatingsystemrelease": [
+ "8"
+ ]
+ },
+ {
+ "operatingsystem": "Ubuntu",
+ "operatingsystemrelease": [
+ "16.04"
+ ]
+ },
+ {
+ "operatingsystem": "windows",
+ "operatingsystemrelease": [
+ "2008 R2",
+ "2012 R2",
+ "10"
+ ]
+ },
+ {
+ "operatingsystem": "Fedora",
+ "operatingsystemrelease": [
+ "25"
+ ]
+ },
+ {
+ "operatingsystem": "Darwin",
+ "operatingsystemrelease": [
+ "16"
+ ]
+ },
+ {
+ "operatingsystem": "SLES",
+ "operatingsystemrelease": [
+ "12"
+ ]
+ },
+ {
+ "operatingsystem": "Solaris",
+ "operatingsystemrelease": [
+ "11"
+ ]
+ }
+ ],
+ "requirements": [
+ {
+ "name": "puppet",
+ "version_requirement": ">= 4.7.0 < 6.0.0"
+ }
+ ],
+ "pdk-version": "1.6.0",
+ "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
+ "template-ref": "1.6.0-0-gf5564c0"
+}
diff --git a/spec/default_facts.yml b/spec/default_facts.yml
new file mode 100644
index 0000000..3248be5
--- /dev/null
+++ b/spec/default_facts.yml
@@ -0,0 +1,8 @@
+# Use default_module_facts.yml for module specific facts.
+#
+# Facts specified here will override the values provided by rspec-puppet-facts.
+---
+concat_basedir: "/tmp"
+ipaddress: "172.16.254.254"
+is_pe: false
+macaddress: "AA:AA:AA:AA:AA:AA"
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..e69d11d
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,45 @@
+
+require 'puppetlabs_spec_helper/module_spec_helper'
+require 'rspec-puppet-facts'
+
+begin
+ require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
+rescue LoadError => loaderror
+ warn "Could not require spec_helper_local: #{loaderror.message}"
+end
+
+include RspecPuppetFacts
+
+default_facts = {
+ puppetversion: Puppet.version,
+ facterversion: Facter.version,
+}
+
+default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml'))
+default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
+
+if File.exist?(default_facts_path) && File.readable?(default_facts_path)
+ default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
+end
+
+if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path)
+ default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path)))
+end
+
+RSpec.configure do |c|
+ c.default_facts = default_facts
+ c.before :each do
+ # set to strictest setting for testing
+ # by default Puppet runs at warning level
+ Puppet.settings[:strict] = :warning
+ end
+end
+
+def ensure_module_defined(module_name)
+ module_name.split('::').reduce(Object) do |last_module, next_module|
+ last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)
+ last_module.const_get(next_module)
+ end
+end
+
+# 'spec_overrides' from sync.yml will appear below this line