Skip to content

Works and fixes #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: 'Static code analysys'
runs-on: ubuntu-latest
timeout-minutes: 10
container: puppet/puppet-dev-tools:4.x
container: puppet/pdk:3.4.0.1.55.g4519dd0
steps:
- uses: actions/checkout@v2
- name: Run static validations
Expand All @@ -20,7 +20,7 @@ jobs:
name: 'Unit tests'
runs-on: ubuntu-latest
timeout-minutes: 60
container: puppet/puppet-dev-tools:4.x
container: puppet/pdk:3.4.0.1.55.g4519dd0
steps:
- uses: actions/checkout@v2
- name: Run unit tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: 'Deploy to forge'
runs-on: ubuntu-latest
if: github.repository_owner == 'example42'
container: puppet/puppet-dev-tools:4.x
container: puppet/pdk:3.4.0.1.55.g4519dd0
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@
/junit/
/log/
/pkg/
/spec/fixtures/modules/
/spec/fixtures/manifests/
/spec/fixtures/modules/*
/tmp/
/vendor/
/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
.resource_types
.modules
.task_cache.json
.plan_cache.json
.rerun.json
bolt-debug.log
16 changes: 10 additions & 6 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,34 @@
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/spec/fixtures/modules/*
/tmp/
/vendor/
/.vendor/
/convert_report.txt
/update_report.txt
.DS_Store
.project
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
/appveyor.yml
/.editorconfig
.resource_types
.modules
.task_cache.json
.plan_cache.json
.rerun.json
bolt-debug.log
/.fixtures.yml
/Gemfile
/.gitattributes
/.github/
/.gitignore
/.gitlab-ci.yml
/.pdkignore
/.puppet-lint.rc
/Rakefile
/rakelib/
/.rspec
/.rubocop.yml
/.travis.yml
/..yml
/.yardopts
/spec/
/.vscode/
Expand Down
12 changes: 8 additions & 4 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
--fail-on-warnings
--relative
# --no-parameter_documentation
# --no-file_ensure-check
# --no-params-empty-string-assignment-check

--no-80chars-check
--no-140chars-check
--no-class_inherits_from_params_class-check
--no-autoloader_layout-check
--no-documentation-check
--no-single_quote_string_with_variables-check
--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"puppet.puppet-vscode",
"rebornix.Ruby"
"Shopify.ruby-lsp"
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## Release 0.1.1

* Puppet 8 support

## Release 0.1.0

* First release with several profiles moved from psick module
Expand Down
62 changes: 40 additions & 22 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,54 @@ def location_for(place_or_version, fake_version = nil)
end
end

ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = ruby_version_segments[0..1].join('.')

group :development do
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 "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby]
gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-module-win-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw]
# gem "voxpupuli-puppet-lint-plugins", '>= 3.0', require: false
gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "deep_merge", '~> 1.2.2', require: false
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
gem "facterdb", '~> 2.1', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "facterdb", '~> 3.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "metadata-json-lint", '~> 4.0', require: false
gem "json-schema", '< 5.1.1', require: false
gem "rspec-puppet-facts", '~> 4.0', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "rspec-puppet-facts", '~> 5.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "dependency_checker", '~> 1.0.0', require: false
gem "parallel_tests", '= 3.12.1', require: false
gem "pry", '~> 0.10', require: false
gem "simplecov-console", '~> 0.9', require: false
gem "puppet-debugger", '~> 1.0', require: false
gem "rubocop", '~> 1.50.0', require: false
gem "rubocop-performance", '= 1.16.0', require: false
gem "rubocop-rspec", '= 2.19.0', require: false
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
end
group :development, :release_prep do
gem "puppet-strings", '~> 4.0', require: false
gem "puppetlabs_spec_helper", '~> 8.0', require: false
gem "puppet-blacksmith", '~> 7.0', require: false
end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby]
gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "serverspec", '~> 2.41', require: false
end

puppet_version = ENV['PUPPET_GEM_VERSION']
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['HIERA_GEM_VERSION']

gems = {}
puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil)
facter_version = ENV.fetch('FACTER_GEM_VERSION', nil)
hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil)

gems['puppet'] = location_for(puppet_version)

# If facter or hiera versions have been specified via the environment
# variables
# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet
# Otherwise, do as before and use location_for to fetch gems from the default source
if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
else
gems['puppet'] = location_for(puppet_version)
gems['facter'] = location_for(facter_version) if facter_version
end

gems['facter'] = location_for(facter_version) if facter_version
gems['hiera'] = location_for(hiera_version) if hiera_version

gems.each do |gem_name, gem_params|
Expand Down
91 changes: 10 additions & 81 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,89 +1,18 @@
# frozen_string_literal: true

require 'bundler'
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus'
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"
returnVal = nil || JSON.load(File.read('metadata.json'))['author']
raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
puts "GitHubChangelogGenerator user:#{returnVal}"
returnVal
end

def changelog_project
return unless Rake.application.top_level_tasks.include? "changelog"

returnVal = nil
returnVal ||= begin
metadata_source = JSON.load(File.read('metadata.json'))['source']
metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z})

metadata_source_match && metadata_source_match[1]
end

raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil?

puts "GitHubChangelogGenerator project:#{returnVal}"
returnVal
end

def changelog_future_release
return unless Rake.application.top_level_tasks.include? "changelog"
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
end
require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'

PuppetLint.configuration.send('disable_relative')


if Bundler.rubygems.find_name('github_changelog_generator').any?
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
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?
config.user = "#{changelog_user}"
config.project = "#{changelog_project}"
config.future_release = "#{changelog_future_release}"
config.exclude_labels = ['maintenance']
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)."
config.add_pr_wo_labels = true
config.issues = false
config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB"
config.configure_sections = {
"Changed" => {
"prefix" => "### Changed",
"labels" => ["backwards-incompatible"],
},
"Added" => {
"prefix" => "### Added",
"labels" => ["enhancement", "feature"],
},
"Fixed" => {
"prefix" => "### Fixed",
"labels" => ["bug", "documentation", "bugfix"],
},
}
end
else
desc 'Generate a Changelog from GitHub'
task :changelog do
raise <<EOM
The changelog tasks depends on recent features of the github_changelog_generator gem.
Please manually add it to your .sync.yml for now, and run `pdk update`:
---
Gemfile:
optional:
':development':
- gem: 'github_changelog_generator'
version: '~> 1.15'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')"
EOM
end
end
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_autoloader_layout')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"]

2 changes: 1 addition & 1 deletion manifests/apache/tp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
settings_hash => $settings_hash,
},
'exec' => {
path => $::path,
path => $facts['path'],
},
'file' => {
ensure => $file_ensure,
Expand Down
4 changes: 2 additions & 2 deletions manifests/crowdsec.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# @example
# include psick_profile::crowdsec
class psick_profile::crowdsec (
String $install_class = 'psick_profile::crowdsec::tp',
Hash $collections_hash = {},
String $install_class = 'psick_profile::crowdsec::tp',
Hash $collections_hash = {},
Boolean $manage = $::psick::manage,
Boolean $noop_manage = $::psick::noop_manage,
Boolean $noop_value = $::psick::noop_value,
Expand Down
2 changes: 1 addition & 1 deletion manifests/docker/tp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
settings_hash => $settings_hash,
},
'exec' => {
path => $::path,
path => $facts['path'],
},
'file' => {
ensure => $file_ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/foreman/tp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
settings_hash => $settings_hash,
},
'exec' => {
path => $::path,
path => $facts['path'],
},
'file' => {
ensure => $file_ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/gitlab.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# @param manage_installation Set to true to atually install GitLab. Default,
# false, just manages symlink in /etc/ssh/auth_keys
# @param use_https Define if you want gitlab services to use ssl.
# @param server_name The name to use for the GitLab website. Default: $::fqdn,
# @param server_name The name to use for the GitLab website. Default: $::networking['fqdn'],
# If you set a name different from the local machine fqdn,
# provide custom cert files via *_file_source params
# @param ca_file_source Puppet source for the ca certificate. By default Puppet CA is
Expand Down
2 changes: 1 addition & 1 deletion manifests/grafana/datasource.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Optional[Hash] $json_data = undef,
Optional[Hash] $secure_json_data = undef,
Optional[Boolean] $editable = undef,
Optional[Hash] $options = {},
Hash $options = {},
) {
tp::conf { "grafana::${file_name}":
content => template($template),
Expand Down
4 changes: 2 additions & 2 deletions manifests/grafana/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
unless => "grafana-cli plugins ls | grep ${plugin} | grep '${version}'",
notify => $exec_notify,
require => $exec_require,
path => $::path,
path => $facts['path'],
}
} else {
exec { "grafana plugins uninstall ${plugin}":
command => "grafana-cli plugins uninstall ${plugin}",
onlyif => "grafana-cli plugins ls | grep ${plugin}",
notify => $exec_notify,
require => $exec_require,
path => $::path,
path => $facts['path'],
}
}
}
2 changes: 1 addition & 1 deletion manifests/grafana/tp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
settings_hash => $settings_hash,
},
'exec' => {
path => $::path,
path => $facts['path'],
},
'file' => {
ensure => $file_ensure,
Expand Down
2 changes: 1 addition & 1 deletion manifests/grafana/user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
exec { "grafana user add ${title}":
command => "${user_dir_path}/${user}_${host}",
require => $exec_require,
path => $::path,
path => $facts['path'],
refreshonly => true,
}
}
Loading
Loading