Showing with 185 additions and 66 deletions.
  1. +1 −1 .gitattributes
  2. +2 −0 .gitignore
  3. +15 −0 .pdkignore
  4. 0 .puppet-lint.rc
  5. +23 −2 .sync.yml
  6. +5 −11 .travis.yml
  7. +8 −0 CHANGELOG.md
  8. +3 −1 Gemfile
  9. +4 −2 README.md
  10. +7 −1 Rakefile
  11. +3 −8 appveyor.yml
  12. +28 −6 metadata.json
  13. +28 −19 spec/acceptance/init_spec.rb
  14. +0 −1 spec/default_facts.yml
  15. +22 −14 spec/spec_helper.rb
  16. +8 −0 spec/spec_helper_acceptance.rb
  17. +28 −0 spec/spec_helper_local.rb
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#This file is generated by ModuleSync, do not edit.
*.rb eol=lf
*.erb eol=lf
*.pp eol=lf
*.sh eol=lf
*.epp eol=lf
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
/convert_report.txt
/update_report.txt
.DS_Store
.vscode/
.envrc
15 changes: 15 additions & 0 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@
/convert_report.txt
/update_report.txt
.DS_Store
.vscode/
.envrc
/appveyor.yml
/.fixtures.yml
/Gemfile
/.gitattributes
/.gitignore
/.gitlab-ci.yml
/.pdkignore
/Rakefile
/.rspec
/.rubocop.yml
/.travis.yml
/.yardopts
/spec/
Empty file added .puppet-lint.rc
Empty file.
25 changes: 23 additions & 2 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---
.gitignore:
required:
- ---.project

.gitlab-ci.yml:
unmanaged: true

.travis.yml:
docker_sets:
- set: docker/centos-7
Expand All @@ -8,6 +15,11 @@
secure: ""
branches:
- release
global_env:
- GEM_BOLT=true
remove_includes:
- env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
rvm: 2.4.4

Gemfile:
optional:
Expand All @@ -25,10 +37,19 @@ Gemfile:
- mswin
- mingw
- x64_mingw
- gem: bolt
version: '~> 1.3'
condition: ENV['GEM_BOLT']

Rakefile:
requires:
- puppet-lint/tasks/puppet-lint
extras: |
# spec_prep is required to setup fixtures used by the acceptance tests
beaker_task = Rake::Task['beaker']
spec_prep = Rake::Task['spec_prep']
beaker_task.enhance(beaker_task.prerequisite_tasks << spec_prep)
.gitlab-ci.yml:
unmanaged: true
spec/spec_helper.rb:
mock_with: ':rspec'
coverage_report: true
16 changes: 5 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
---
sudo: false
dist: trusty
language: ruby
cache: bundler
before_install:
- bundle -v
- rm -f Gemfile.lock
- gem update --system
- gem update --system $RUBYGEMS_VERSION
- gem --version
- bundle -v
script:
- 'bundle exec rake $CHECK'
bundler_args: --without system_tests
rvm:
- 2.5.0
- 2.5.1
env:
global:
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0"
- GEM_BOLT=true
matrix:
fast_finish: true
include:
-
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply
rvm: 2.5.0
rvm: 2.5.1
script: bundle exec rake beaker
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
rvm: 2.5.0
rvm: 2.5.1
script: bundle exec rake beaker
services: docker
sudo: required
-
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="~> 5.0" CHECK=parallel_spec
rvm: 2.4.4
-
env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
rvm: 2.1.9
branches:
only:
- master
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All 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).

## [0.4.1](https://github.com/puppetlabs/puppetlabs-facter_task/tree/0.4.1) (2019-04-05)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-facter_task/compare/0.4.0...0.4.1)

### Fixed

- pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#55](https://github.com/puppetlabs/puppetlabs-facter_task/pull/55) ([tphoney](https://github.com/tphoney))

## [0.4.0](https://github.com/puppetlabs/puppetlabs-facter_task/tree/0.4.0) (2018-09-28)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-facter_task/compare/0.3.1...0.4.0)
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ group :development do
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 "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
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))
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]
Expand All @@ -31,6 +32,7 @@ end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "bolt", '~> 1.3', require: false if ENV['GEM_BOLT']
end

puppet_version = ENV['PUPPET_GEM_VERSION']
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ This module provides the facter_task task. This task allows you to discover fact
## Requirements
This module is compatible with Puppet Enterprise and Puppet Bolt.

* To run tasks with Puppet Enterprise, PE 2017.3 or later must be installed on the machine from which you are running task commands. Machines receiving task requests must be Puppet agents.
* To run tasks with Puppet Enterprise, PE 2018.1 or later must be installed on the machine from which you are running task commands. Machines receiving task requests must be Puppet agents.

* To run tasks with Puppet Bolt, Bolt 0.5 or later must be installed on the machine from which you are running task commands. Machines receiving task requests must have SSH or WinRM services enabled.
* To run tasks with Puppet Bolt, Bolt 1.0 or later must be installed on the machine from which you are running task commands. Machines receiving task requests must have SSH or WinRM services enabled.

## Usage

Expand All @@ -43,6 +43,8 @@ For a complete list of facts that are supported, see the Puppet [core facts](htt

## Limitations

To run acceptance tests against Windows machines locally, ensure that the `BEAKER_password` environment variable has been set to the password of the Administrator user of the target machine.

For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-facter_task/blob/master/metadata.json)

## Getting Help
Expand Down
8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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?
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
require 'puppet-lint/tasks/puppet-lint'

def changelog_user
Expand All @@ -22,7 +23,7 @@ end

def changelog_future_release
return unless Rake.application.top_level_tasks.include? "changelog"
returnVal = JSON.load(File.read('metadata.json'))['version']
returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
puts "GitHubChangelogGenerator future_release:#{returnVal}"
returnVal
Expand Down Expand Up @@ -74,3 +75,8 @@ EOM
end
end

# spec_prep is required to setup fixtures used by the acceptance tests
beaker_task = Rake::Task['beaker']
spec_prep = Rake::Task['spec_prep']
beaker_task.enhance(beaker_task.prerequisite_tasks << spec_prep)

11 changes: 3 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
version: 1.1.x.{build}
branches:
only:
- master
skip_commits:
message: /^\(?doc\)?.*/
clone_depth: 10
Expand All @@ -14,14 +17,6 @@ environment:
-
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
Expand Down
34 changes: 28 additions & 6 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-facter_task",
"version": "0.4.0",
"version": "0.4.1",
"author": "puppetlabs",
"summary": "Tasks that inspect the value of system facts",
"license": "Apache-2.0",
Expand All @@ -16,23 +16,45 @@
"9"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"7.0"
"5",
"6",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04",
"16.04",
"18.04"
]
},
{
"operatingsystem": "windows",
"operatingsystemrelease": [
"2012 R2"
"2008 R2",
"2012 R2",
"10",
"2016"
]
}
],
Expand All @@ -43,7 +65,7 @@
}
],
"description": "Tasks that inspect the value of system facts",
"pdk-version": "1.7.0",
"pdk-version": "1.8.0",
"template-url": "https://github.com/puppetlabs/pdk-templates",
"template-ref": "heads/master-0-g8fc95db"
}
"template-ref": "heads/master-0-gfde5699"
}
47 changes: 28 additions & 19 deletions spec/acceptance/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,47 @@
require 'spec_helper_acceptance'

describe 'facter_task task' do
include Beaker::TaskHelper::Inventory
include BoltSpec::Run

operating_system_fact = fact('operatingsystem')
os_family_fact = fact('osfamily')

describe 'puppet facts' do
describe 'facter_task' do
it 'get a puppet fact' do
result = run_task(task_name: 'facter_task', params: 'fact=osfamily', format: 'json')
expect(result['status']).to eq('success')
expect(result['result']).to eq('osfamily' => os_family_fact)
result = run_task(task_name: 'facter_task', params: 'fact=operatingsystem', format: 'json')
expect(result['status']).to eq('success')
expect(result['result']).to eq('operatingsystem' => operating_system_fact)
result = task_run('facter_task', 'fact' => 'osfamily')

expect(result.first['status']).to eq('success')
expect(result.first['result']).to eq('osfamily' => os_family_fact)

result = task_run('facter_task', 'fact' => 'operatingsystem')

expect(result.first['status']).to eq('success')
expect(result.first['result']).to eq('operatingsystem' => operating_system_fact)
end

it 'get a structured fact' do
result = run_task(task_name: 'facter_task', params: 'fact=os', format: 'json')
expect(result['status']).to eq('success')
expect(result['result']).to include('os')
expect(result['result']['os']['family']).to eq(os_family_fact)
expect(result['result']['os']['name']).to eq(operating_system_fact)
result = task_run('facter_task', 'fact' => 'os')

expect(result.first['status']).to eq('success')
expect(result.first['result']).to include('os')
expect(result.first['result']['os']['family']).to eq(os_family_fact)
expect(result.first['result']['os']['name']).to eq(operating_system_fact)
end

it 'gets all facts' do
result = run_task(task_name: 'facter_task', format: 'json')
expect(result['status']).to eq('success')
expect(result['result']).to include('os', 'networking', 'kernel')
result = task_run('facter_task', {})

expect(result.first['status']).to eq('success')
expect(result.first['result']).to include('os', 'networking', 'kernel')
end

it 'fails cleanly' do
result = run_task(task_name: 'facter_task', params: 'fact=--foo', format: 'json')
expect(result['status']).to eq('failure')
expect(result['result']['_error']['kind']).to eq('facter_task/failure')
expect(result['result']['_error']['msg']).to match(
result = task_run('facter_task', 'fact' => '--foo')

expect(result.first['status']).to eq('failure')
expect(result.first['result']['_error']['kind']).to eq('facter_task/failure')
expect(result.first['result']['_error']['msg']).to match(
%r{Exit 1 running .*bin/facter.* -p --json --foo: error: unrecognised option '--foo'},
)
end
Expand Down
1 change: 0 additions & 1 deletion spec/default_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# Facts specified here will override the values provided by rspec-puppet-facts.
---
concat_basedir: ""
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
Loading