Skip to content
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

Facter #120

Merged
merged 2 commits into from
Oct 22, 2023
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
34 changes: 22 additions & 12 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
name: 'Syntax validation'
runs-on: ubuntu-latest
timeout-minutes: 10
container: puppet/puppet-dev-tools:4.x
container: puppet/pdk:3.0.0.0
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run static validations
run: /usr/local/bin/pdk bundle exec rake validate lint check
env:
Expand All @@ -20,20 +20,30 @@ jobs:
name: 'Unit tests'
runs-on: ubuntu-latest
timeout-minutes: 60
container: puppet/puppet-dev-tools:4.x
# container: puppet/puppet-dev-tools:4.x
container: puppet/pdk:3.0.0.0
steps:
- uses: actions/checkout@v2
- name: Run unit tests on current puppet
# run: /usr/local/bin/pdk bundle exec rake spec
run: /usr/local/bin/pdk test unit
- uses: actions/checkout@v4
- name: Run unit tests on Puppet 8
run: /usr/local/bin/pdk test unit --puppet-version=8
env:
BUNDLE_WITHOUT: development:system_tests:release
- name: Run unit tests on Puppet 6
run: /usr/local/bin/pdk test unit --puppet-version=6
continue-on-error: true
- name: Run unit tests on Puppet 7
run: /usr/local/bin/pdk test unit --puppet-version=7
env:
BUNDLE_WITHOUT: development:system_tests:release
- name: Run unit tests on Puppet 5
run: /usr/local/bin/pdk test unit --puppet-version=5
continue-on-error: true

unit_legacy:
name: 'Unit tests Legacy Puppet'
runs-on: ubuntu-latest
timeout-minutes: 60
container: puppet/puppet-dev-tools:4.x
steps:
- uses: actions/checkout@v4
- name: Run unit tests on Puppet 6
run: /usr/local/bin/pdk test unit --puppet-version=6
env:
BUNDLE_WITHOUT: development:system_tests:release
continue-on-error: true
continue-on-error: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/spec/fixtures/modules/*
/tmp/
/vendor/
/convert_report.txt
Expand Down
8 changes: 2 additions & 6 deletions .pdkignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/spec/fixtures/modules/*
/tmp/
/vendor/
/convert_report.txt
Expand All @@ -26,20 +26,16 @@
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
/appveyor.yml
/.editorconfig
/.fixtures.yml
/Gemfile
/.gitattributes
/.gitignore
/.gitlab-ci.yml
/.pdkignore
/.puppet-lint.rc
/Rakefile
/rakelib/
/.rspec
/.rubocop.yml
/.travis.yml
/..yml
/.yardopts
/spec/
/.vscode/
Expand Down
1 change: 1 addition & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--relative
--no-parameter_documentation-check
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## Changelog

## Release 1.1.0

- More updates for full Puppet 8 compatibility
- Added psick::puppet::facter profile to manage facter.conf
- pdk update
- Make psick::tools::create_dir windows compatible
- Several lints and fixes
- Define psick::git::clone to clone and sync a git repo
- psick::ruby::rbenv has no more a default ruby version

## Release 1.0.4

- Updated psick::timezone to support more recent Debian derivatives
Expand Down
50 changes: 26 additions & 24 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,33 @@ def location_for(place_or_version, fake_version = nil)
end

group :development do
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', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
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 "voxpupuli-puppet-lint-plugins", '~> 3.1', require: false
gem "facterdb", '~> 1.18', require: false
gem "metadata-json-lint", '>= 2.0.2', '< 4.0.0', require: false
gem "puppetlabs_spec_helper", '~> 4.0', require: false
gem "rspec-puppet-facts", '~> 2.0', require: false
gem "codecov", '~> 0.2', require: false
gem "dependency_checker", '~> 0.2', require: false
gem "parallel_tests", '~> 3.4', require: false
gem "pry", '~> 0.10', require: false
gem "simplecov-console", '~> 0.5', require: false
gem "puppet-debugger", '~> 1.0', require: false
gem "rubocop", '= 1.6.1', require: false
gem "rubocop-performance", '= 1.9.1', require: false
gem "rubocop-rspec", '= 2.0.1', require: false
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
end
group :system_tests do
gem "puppet_litmus", '< 1.0.0', require: false, platforms: [:ruby, :x64_mingw]
gem "serverspec", '~> 2.41', require: false
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', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
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 "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
gem "facterdb", '~> 1.18', require: false
gem "metadata-json-lint", '~> 3.0', require: false
gem "puppetlabs_spec_helper", '~> 6.0', require: false
gem "rspec-puppet-facts", '~> 2.0', require: false
gem "codecov", '~> 0.2', require: false
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.5', require: false
gem "puppet-debugger", '~> 1.0', require: false
gem "rubocop", '= 1.48.1', require: false
gem "rubocop-performance", '= 1.16.0', require: false
gem "rubocop-rspec", '= 2.19.0', require: false
gem "puppet-strings", '~> 2.0', require: false
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
end
#group :system_tests do
# gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
# gem "serverspec", '~> 2.41', require: false
#end

puppet_version = ENV['PUPPET_GEM_VERSION']
facter_version = ENV['FACTER_GEM_VERSION']
Expand Down
9 changes: 4 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# 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?
require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator'
require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'

def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
Expand Down Expand Up @@ -44,7 +43,7 @@ end
PuppetLint.configuration.send('disable_relative')


if Bundler.rubygems.find_name('github_changelog_generator').any?
if Gem.loaded_specs.key? 'github_changelog_generator'
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}"
Expand Down
3 changes: 2 additions & 1 deletion data/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ psick::puppet::pe_agent::config_file_path: 'c:/programdata/puppetlabs/puppet/etc
psick::puppet::postrun::puppet_conf_path: 'c:/programdata/puppetlabs/puppet/etc/puppet.conf'
psick::puppet::pe_client_tools::repo_path: 'windows'
psick::puppet::pe_client_tools::package_suffix: '-x64.msi'
psick::puppet::pe_client_tools::package_download_dir: 'c:/tmp'
psick::puppet::pe_client_tools::package_download_dir: 'c:/tmp'
psick::puppet::facter::config_file_dir: 'c:/programdata/puppetlabs/facter/etc'
6 changes: 3 additions & 3 deletions docs/hosts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ psick::hosts::file class manages /etc/hosts
To customise its behaviour you can set the template to use to manage ```/etc/hosts```, and the ipaddress, domain and hostname values for the local node (by default the relevant facts values are used):

psick::hosts::file::template: 'psick/hosts/file/hosts.erb' # Default value
psick::hosts::file::ipaddress: '10.0.0.4' # Default: $::ipaddress
psick::hosts::file::domain: 'domain.com' # Default: $::domain
psick::hosts::file::hostname: 'www01' # Default: $::hostname
psick::hosts::file::ipaddress: '10.0.0.4' # Default: $::networking['ip']
psick::hosts::file::domain: 'domain.com' # Default: $::networking['domain']
psick::hosts::file::hostname: 'www01' # Default: $::networking['hostname']


58 changes: 56 additions & 2 deletions manifests/admin.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,58 @@
# @class admin
# This class manages an admin user and SSH access on Puppet managed nodes.
#
# == Parameters
#
# [*ensure*]
# Whether the admin user should be present or absent. Defaults to `present`.
#
# [*user_class*]
# The name of the class that manages the admin user on infrastructure nodes. Defaults to `::psick::admin::user`.
# Note: If default is changed other params of this class might not be used.
#
# [*master_class*]
# The name of the class that manages the central master node from which ssh access is granted. Defaults to `::psick::admin::master`.
# Note: If default is changed other params of this class might not be used.
#
# [*node_class*]
# The name of the class that manages nodes which allow access from master node. Defaults to `::psick::admin::node`.
# Note: If default is changed other params of this class might not be used.
#
# [*user*]
# The name of the admin user. Defaults to `admin`.
#
# [*master*]
# The hostname or IP address of the master node. Defaults to `''`.
#
# [*keyshare_method*]
# The method used to share SSH keys between nodes and the master node. Defaults to `storeconfigs`.
#
# [*auto_prereq*]
# Whether to automatically include prerequisite classes. Defaults to the value of `$psick::auto_prereq`.
#
# [*master_enable*]
# Whether to enable master management. If true, master class is included and node is a master. Defaults to `false`.
#
# [*node_enable*]
# Whether to enable node management. If true, node class is included and node can bve controlled from master. Defaults to `true`.
#
# [*manage*]
# Whether to manage any resource on this class. Defaults to the value of `$psick::manage`.
#
# [*noop_manage*]
# Whether to manage noop for this class resources. Defaults to the value of `$psick::noop_manage`.
#
# [*noop_value*]
# The value to use for noop mode. Defaults to the value of `$psick::noop_value`.
#
# == Example
#
# To manage the admin user and SSH access from master node, just include the `psick::admin` class:
#
# include psick::admin
#
# Via Hiera on the master node set:
#
# psick::admin::master_enable: true
#
class psick::admin (

Expand All @@ -10,7 +64,7 @@

String $user = 'admin',

String $master = '',
String $master = '', # lint:ignore:params_empty_string_assignment
Variant[Undef,String] $keyshare_method = 'storeconfigs',

Boolean $auto_prereq = $psick::auto_prereq,
Expand Down
6 changes: 3 additions & 3 deletions manifests/admin/master.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
include psick::admin

if $psick::admin::keyshare_method == 'storeconfigs'
and ($ssh_key or $::admin_user_key) {
@@ssh_authorized_key { "admin_user_${psick::admin::user}_rsa-${clientcert}":
and ($ssh_key or getvar('facts.admin_user_key')) {
@@ssh_authorized_key { "admin_user_${psick::admin::user}_rsa-${facts['clientcert']}":
ensure => $ensure,
key => pick($ssh_key,$::admin_user_key),
key => pick($ssh_key,getvar('facts.admin_user_key')),
user => $psick::admin::user,
type => 'rsa',
tag => "admin_master_${psick::admin::master}",
Expand Down
2 changes: 1 addition & 1 deletion manifests/archive.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Enum['download','extract','compress','auto'] $action = 'auto',

Optional[String] $source = $title,
Optional[Stdlib::Absolutepath] $download_dir = '/var/tmp',
Stdlib::Absolutepath $download_dir = '/var/tmp',
Optional[String] $download_command = undef,
Integer $download_timeout = 600,
Array $download_exec_env = [],
Expand Down
12 changes: 6 additions & 6 deletions manifests/aws.pp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#
class psick::aws (
String $region = chop($::ec2_placement_availability_zone),
String $region = chop($facts['ec2_placement_availability_zone']),

String $default_vpc_name = 'myvpc',
String $default_cidr_block_prefix = '10.0',
Boolean $create_defaults = false,

String $cli_class = '::psick::aws::cli',
String $puppet_class = '',
String $vpc_class = '',
String $sg_class = '',
String $ec2_class = '',
String $rds_class = '',
String $puppet_class = '', # lint:ignore:params_empty_string_assignment
String $vpc_class = '', # lint:ignore:params_empty_string_assignment
String $sg_class = '', # lint:ignore:params_empty_string_assignment
String $ec2_class = '', # lint:ignore:params_empty_string_assignment
String $rds_class = '', # lint:ignore:params_empty_string_assignment

Boolean $manage = $psick::manage,
Boolean $noop_manage = $psick::noop_manage,
Expand Down
4 changes: 2 additions & 2 deletions manifests/aws/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
class psick::aws::cli (
String $ensure = 'present',
String $region = $psick::aws::region,
String $aws_access_key_id = '',
String $aws_secret_access_key = '',
String $aws_access_key_id = '', # lint:ignore:params_empty_string_assignment
String $aws_secret_access_key = '', # lint:ignore:params_empty_string_assignment
String $config_template = 'psick/aws/credentials.erb',
Array $install_gems = ['aws-sdk-core' , 'retries'],
Boolean $install_system_gems = true,
Expand Down
2 changes: 1 addition & 1 deletion manifests/aws/cli/script.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Boolean $autorun = true,
String $destination_dir = '/var/tmp',
Variant[Undef,String] $region = undef,
String $command = '',
String $command = '', # lint:ignore:params_empty_string_assignment
) {
$script_path = "${destination_dir}/${title}"
$exec_command = $command ? {
Expand Down
Loading
Loading