Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.erb eol=lf
*.pp eol=lf
*.sh eol=lf
*.epp eol=lf
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@
/convert_report.txt
/update_report.txt
.DS_Store
.Puppetfile.pdqtest
8 changes: 7 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ AllCops:
Metrics/LineLength:
Description: People have wide screens, use them.
Max: 200
GetText/DecorateString:
Description: We don't want to decorate test output.
Exclude:
- spec/*
RSpec/BeforeAfterAll:
Description: Beware of using after(:all) as it may cause state to leak between tests.
A necessary evil in acceptance testing.
Expand Down Expand Up @@ -64,7 +68,7 @@ Style/TrailingCommaInLiteral:
and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/SymbolArray:
Description: Using style obscures symbolic intent of array's contents.
Description: Using percent style obscures symbolic intent of array's contents.
EnforcedStyle: brackets
RSpec/MessageSpies:
EnforcedStyle: receive
Expand All @@ -78,6 +82,8 @@ Style/CollectionMethods:
Enabled: true
Style/MethodCalledOnDoEndBlock:
Enabled: true
Style/HashSyntax:
Enabled: false
Style/StringMethods:
Enabled: true
Layout/EndOfLine:
Expand Down
60 changes: 40 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
# .travis.yml
#
# To debug travis locally:
# https://docs.travis-ci.com/user/common-build-problems/#Running-a-Container-Based-Docker-Image-Locally
---
sudo: false

# Don't process the PDK Gemfile - causes big problems!
gemfile: .pdqtest/Gemfile

bundler_args: --path .pdqtest
dist: trusty
language: ruby
services:
- docker
cache: bundler
before_install:
- wget https://apt.puppetlabs.com/puppet5-release-trusty.deb
- sudo dpkg -i puppet5-release-trusty.deb
- sudo apt-get update
- sudo apt install -y pdk

# travis itself does the bundle isntall for us, so we are ready to run now
- bundle -v
- rm -f Gemfile.lock
- gem update --system
- gem --version
- bundle -v
script:
- make setup
- make
- 'bundle exec rake $CHECK'
bundler_args: --without system_tests
rvm:
- 2.4.1
- 2.5.1
env:
global:
- BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.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="~> 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
- /^v\d/
notifications:
email: false
deploy:
provider: puppetforge
user: puppet
password:
secure: ""
on:
tags: true
all_branches: true
condition: "$DEPLOY_TO_FORGE = yes"
22 changes: 7 additions & 15 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
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
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
file_url_regex = %r{\Afile:\/\/(?<path>.*)}

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
if place_or_version && (git_url = place_or_version.match(git_url_regex))
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
else
:gem
[place_or_version, { require: false }]
end
end

Expand All @@ -36,7 +29,6 @@ group :development do
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']

Expand Down
1 change: 1 addition & 0 deletions 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?

def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
Expand Down
11 changes: 11 additions & 0 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 Down Expand Up @@ -30,6 +33,14 @@ environment:
PUPPET_GEM_VERSION: ~> 5.0
RUBY_VERSION: 24-x64
CHECK: parallel_spec
-
PUPPET_GEM_VERSION: ~> 6.0
RUBY_VERSION: 25
CHECK: parallel_spec
-
PUPPET_GEM_VERSION: ~> 6.0
RUBY_VERSION: 25-x64
CHECK: parallel_spec
matrix:
fast_finish: true
install:
Expand Down
10 changes: 6 additions & 4 deletions lib/facter/os_patching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
end
else
Facter.add('os_patching', :type => :aggregate) do
confine { Facter.value(:kernel) == 'windows' or Facter.value(:kernel) == 'Linux' }
confine { Facter.value(:kernel) == 'windows' || Facter.value(:kernel) == 'Linux' }
require 'time'
now = Time.now.iso8601
warnings = {}
Expand All @@ -32,7 +32,7 @@
updates = File.open(updatefile, 'r').read
updates.each_line do |line|
next unless line =~ /[A-Za-z0-9]+/
next if line.match(/^#|^$/)
next if line =~ /^#|^$/
line.sub! 'Title : ', ''
updatelist.push line.chomp
end
Expand All @@ -55,7 +55,7 @@
secupdates = File.open(secupdatefile, 'r').read
secupdates.each_line do |line|
next if line.empty?
next if line.match(/^#|^$/)
next if line =~ /^#|^$/
secupdatelist.push line.chomp
end
else
Expand All @@ -77,9 +77,10 @@
blackouts = File.open(blackoutfile, 'r').read
blackouts.each_line do |line|
next if line.empty?
next if line.match(/^#|^$/)
next if line =~ /^#|^$/
matchdata = line.match(/^([\w ]*),(\d{,4}-\d{1,2}-\d{1,2}T\d{,2}:\d{,2}:\d{,2}\+\d{,2}:\d{,2}),(\d{,4}-\d{1,2}-\d{1,2}T\d{,2}:\d{,2}:\d{,2}[-\+]\d{,2}:\d{,2})$/)
if matchdata
# rubocop:disable Metrics/BlockNesting
arraydata[matchdata[1]] = {} unless arraydata[matchdata[1]]
if matchdata[2] > matchdata[3]
arraydata[matchdata[1]]['start'] = 'Start date after end date'
Expand All @@ -94,6 +95,7 @@
data['blocked'] = true
data['blocked_reasons'].push matchdata[1]
end
# rubocop:enable Metrics/BlockNesting
else
warnings['blackouts'] = "Invalid blackout entry : #{line}"
data['blocked'] = true
Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"version_requirement": ">= 5.3.2 < 6.0.0"
}
],
"pdk-version": "1.7.0",
"pdk-version": "1.8.0",
"template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
"template-ref": "1.7.0-0-g57412ed"
}
"template-ref": "1.8.0-0-g0d9da00"
}
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: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
24 changes: 14 additions & 10 deletions spec/mock/facts_face.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
require 'puppet/node/facts'

Puppet::Indirector::Face.define(:facts, '0.0.1') do
copyright "Puppet Inc.", 2011
license _("Apache 2 license; see COPYING")
copyright 'Puppet Inc.', 2011
license _('Apache 2 license; see COPYING')

summary _("Retrieve and store facts.")
summary _('Retrieve and store facts.')
description <<-'EOT'
This subcommand manages facts, which are collections of normalized system
information used by Puppet. It can read facts directly from the local system
(with the default `facter` terminus).
EOT

find = get_action(:find)
find.summary _("Retrieve a node's facts.")
find.arguments _("[<node_certname>]")
find.summary _('Retrieve a nodes facts.')
find.arguments _('[<node_certname>]')
find.returns <<-'EOT'
A hash containing some metadata and (under the "values" key) the set
A hash containing some metadata and (under the 'values' key) the set
of facts for the requested node. When used from the Ruby API: A
Puppet::Node::Facts object.

Expand All @@ -40,12 +40,12 @@
deactivate_action(:search)

action(:upload) do
summary _("Upload local facts to the puppet master.")
summary _('Upload local facts to the puppet master.')
description <<-'EOT'
Reads facts from the local system using the `facter` terminus, then
saves the returned facts using the rest terminus.
EOT
returns "Nothing."
returns 'Nothing.'
notes <<-'EOT'
This action requires that the puppet master's `auth.conf` file
allow `PUT` or `save` access to the `/puppet/v3/facts` API endpoint.
Expand All @@ -66,7 +66,9 @@

render_as :json

# rubocop:disable Lint/UnusedBlockArgument
when_invoked do |options|
# rubocop:enable Lint/UnusedBlockArgument
# Use `agent` sections settings for certificates, Puppet Server URL,
# etc. instead of `user` section settings.
Puppet.settings.preferred_run_mode = :agent
Expand All @@ -80,13 +82,15 @@

Puppet::Node::Facts.indirection.terminus_class = :rest
server = Puppet::Node::Facts::Rest.server
# rubocop:disable Layout/SpaceInsideHashLiteralBraces, Layout/MultilineHashBraceLayout, Layout/IndentHash
Puppet.notice(_("Uploading facts for '%{node}' to: '%{server}'") % {
node: Puppet[:node_name_value],
server: server})
# rubocop:enable Layout/SpaceInsideHashLiteralBraces, Layout/MultilineHashBraceLayout, Layout/IndentHash

Puppet.notice("Not really uploading facts (JKS - LOL) - mock version!")
Puppet.notice('Not really uploading facts (JKS - LOL) - mock version!')
# do not upload to non-existant puppet server
#Puppet::Node::Facts.indirection.save(facts)
# Puppet::Node::Facts.indirection.save(facts)
end
end
end
28 changes: 14 additions & 14 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
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
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))

include RspecPuppetFacts

Expand All @@ -14,15 +10,19 @@
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'))
default_fact_files = [
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
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
default_fact_files.each do |f|
next unless File.exist?(f) && File.readable?(f) && File.size?(f)

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)))
begin
default_facts.merge!(YAML.safe_load(File.read(f)))
rescue => e
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
end
end

RSpec.configure do |c|
Expand All @@ -36,8 +36,8 @@

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)
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
last_module.const_get(next_module, false)
end
end

Expand Down
2 changes: 1 addition & 1 deletion tasks/clean_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ def err(code, kind, message, starttime)
# Clean that cache!
clean_out, stderr, status = Open3.capture3(clean_cache)
err(status, 'os_patching/clean_cache', stderr, starttime) if status != 0
output(status,'Cache cleaned',clean_out,starttime)
output(status, 'Cache cleaned', clean_out, starttime)
log.info 'Cache cleaned'
Loading