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

Devel #114

Merged
merged 12 commits into from
Oct 19, 2023
Merged

Devel #114

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
16 changes: 12 additions & 4 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.0.0.0
steps:
- uses: actions/checkout@v3
- name: Run static validations
Expand All @@ -20,10 +20,18 @@ jobs:
name: 'Unit tests'
runs-on: ubuntu-latest
timeout-minutes: 60
container: puppet/puppet-dev-tools:4.x
container: puppet/pdk:3.0.0.0
steps:
- uses: actions/checkout@v3
- name: Run unit tests
run: /usr/local/bin/pdk bundle exec rake spec
- name: Run unit tests on Puppet 8
run: /usr/local/bin/pdk test unit --puppet-version=8 --parallel
env:
BUNDLE_WITHOUT: development:system_tests:release
continue-on-error: true
- name: Run unit tests on Puppet 7
run: /usr/local/bin/pdk test unit --puppet-version=7 --parallel
env:
BUNDLE_WITHOUT: development:system_tests:release
continue-on-error: true


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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## 3.10.1

- Changed CI containers used
- Unit tests for Puppet 7 and 8
- Lints and fix on undefined vars
- Updated tp::create_dir

## 3.10.0

- Added support for $MAJVERSION variable in tinydata
Expand Down
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ group :development do
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", '~> 3.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
#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
2 changes: 1 addition & 1 deletion README-legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Configure the application main configuration file a custom erb template which us

tp::conf { 'rsyslog':
template => 'site/rsyslog/rsyslog.conf.erb',
options_hash => hiera('rsyslog::options_hash'),
options_hash => lookup('rsyslog::options_hash'),
}

Populate any custom directory from a Git repository (it requires Puppet Labs' vcsrepo module):
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Configure the application main configuration file a custom erb template which us

tp::conf { 'rsyslog':
template => 'site/rsyslog/rsyslog.conf.erb',
options_hash => hiera('rsyslog::options_hash'),
options_hash => lookup('rsyslog::options_hash'),
}

Populate any custom directory from a Git repository (it requires Puppet Labs' vcsrepo module):
Expand Down
2 changes: 1 addition & 1 deletion manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class tp::cli (
Enum['present','absent'] $ensure = 'present',
Boolean $manage_tp = true,
Hash $tp_commands = lookup('tp::tp_commands', {}),
Hash $tp_commands = pick($tp::tp_commands, {}),

Hash $options = {},
Boolean $purge_dirs = true,
Expand Down
26 changes: 13 additions & 13 deletions manifests/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#
# tp::conf { 'openssh':
# template => 'site/openssh/sshd_config',
# options_hash => hiera('openssh::options_hash'),
# options_hash => lookup('openssh::options_hash'),
# }
#
#
Expand Down Expand Up @@ -237,7 +237,7 @@
Variant[Undef,String] $owner = undef,
Variant[Undef,String] $group = undef,

String $path_prefix = '',
String $path_prefix = '', # lint:ignore:params_empty_string_assignment
Boolean $path_parent_create = false,

Variant[Boolean,String] $config_file_notify = true,
Expand Down Expand Up @@ -300,20 +300,20 @@
$real_path = "${path_prefix}${calculated_path}"

$local_file_params = delete_undef_values({
'path' => $real_path,
'mode' => $mode,
'owner' => $owner,
'group' => $group,
'path' => $real_path,
'mode' => $mode,
'owner' => $owner,
'group' => $group,
})

$local_settings = delete_undef_values({
"${prefix}files" => {
"${base_file}" => $local_file_params,
},
"${base_file}_file_mode" => $mode,
"${base_file}_file_owner" => $owner,
"${base_file}_file_group" => $group,
"${base_file}_file_path" => $real_path,
"${prefix}files" => {
"${base_file}" => $local_file_params,
},
"${base_file}_file_mode" => $mode,
"${base_file}_file_owner" => $owner,
"${base_file}_file_group" => $group,
"${base_file}_file_path" => $real_path,
})
$settings = deep_merge($tp_settings,$settings_hash,$my_settings,$local_settings)

Expand Down
58 changes: 35 additions & 23 deletions manifests/create_dir.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,46 @@
define tp::create_dir (
Optional[String] $owner = undef,
Optional[String] $group = undef,
Optional[String] $mode = undef,
Optional[Stdlib::Filemode] $mode = undef,
Stdlib::AbsolutePath $path = $title,
) {
exec { "mkdir -p ${title}":
command => "mkdir -p ${path}",
path => $facts['path'],
creates => $path,
$mkdir_command = $facts['os']['family'] ? {
'windows' => "New-Item -ItemType Directory -Force -Path '${path}'",
default => "mkdir -p '${path}'",
}
if $owner {
exec { "chown ${owner} ${title}":
command => "chown ${owner} ${path}",
path => $facts['path'],
onlyif => "[ $(ls -ld ${path} | awk '{ print \$3 }') != ${owner} ]",
}
$command_provider = $facts['os']['family'] ? {
'windows' => 'powershell',
default => undef,
}
if $group {
exec { "chgrp ${group} ${title}":
command => "chgrp ${group} ${path}",
path => $facts['path'],
onlyif => "[ $(ls -ld ${path} | awk '{ print \$4 }') != ${group} ]",
}

exec { "Create directory ${title}":
command => $mkdir_command,
path => $facts['path'],
creates => $path,
provider => $command_provider,
}
if $mode {
exec { "chmod ${mode} ${title}":
command => "chmod ${mode} ${path}",
path => $facts['path'],
subscribe => Exec["mkdir -p ${title}"],
refreshonly => true,

if $facts['os']['family'] != 'windows' {
if $owner {
exec { "chown ${owner} ${title}":
command => "chown '${owner}' '${path}'",
path => $facts['path'],
onlyif => "[ \$(stat -c '%U' '${path}') != '${owner}' ]",
}
}
if $group {
exec { "chgrp ${group} ${title}":
command => "chgrp '${group}' '${path}'",
path => $facts['path'],
onlyif => "[ \$(stat -c '%G' '${path}') != '${group}' ]",
}
}
if $mode {
exec { "chmod ${mode} ${title}":
command => "chmod '${mode}' '${path}'",
path => '/bin:/sbin:/usr/sbin:/usr/bin',
onlyif => "[ 0\$(stat -c '%a' '${path}') != '${mode}' ]",
}
}
}
}
40 changes: 20 additions & 20 deletions manifests/dir.pp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@

Enum['global','user'] $scope = 'global',

String $path_prefix = '',
String $path_prefix = '', # lint:ignore:params_empty_string_assignment
Boolean $path_parent_create = false,

Variant[Boolean,String] $config_dir_notify = true,
Expand Down Expand Up @@ -213,30 +213,30 @@
$real_path = "${path_prefix}${calculated_path}"

$local_file_params = delete_undef_values({
'path' => $real_path,
'mode' => $mode,
'owner' => $owner,
'group' => $group,
'recurse' => $recurse,
'purge' => $purge,
'force' => $force,
'path' => $real_path,
'mode' => $mode,
'owner' => $owner,
'group' => $group,
'recurse' => $recurse,
'purge' => $purge,
'force' => $force,
})

$local_settings = delete_undef_values({
"${prefix}dirs" => {
"${base_dir}" => $local_file_params,
},
"${base_dir}_dir_mode" => $mode,
"${base_dir}_dir_owner" => $owner,
"${base_dir}_dir_group" => $group,
"${base_dir}_dir_path" => $real_path,
"${base_dir}_dir_recurse" => $recurse,
"${base_dir}_dir_purge" => $purge,
"${base_dir}_dir_force" => $force,
"${prefix}dirs" => {
"${base_dir}" => $local_file_params,
},
"${base_dir}_dir_mode" => $mode,
"${base_dir}_dir_owner" => $owner,
"${base_dir}_dir_group" => $group,
"${base_dir}_dir_path" => $real_path,
"${base_dir}_dir_recurse" => $recurse,
"${base_dir}_dir_purge" => $purge,
"${base_dir}_dir_force" => $force,
})

$settings = deep_merge($tp_settings,$settings_hash,$my_settings,$local_settings)
$real_mode = pick_default(getvar("settings.${base_dir}_dir_mode"), getvar("settings.${prefix}dirs.${base_dir}.mode"), getvar('settings.config_dir_mode'), undef)
$real_mode = pick_default(getvar("settings.${base_dir}_dir_mode"), getvar("settings.${prefix}dirs.${base_dir}.mode"), getvar('settings.config_dir_mode'), '0755')
$real_owner = pick_default(getvar("settings.${base_dir}_dir_owner"), getvar("settings.${prefix}dirs.${base_dir}.owner"), getvar('settings.config_dir_owner'), undef)
$real_group = pick_default(getvar("settings.${base_dir}_dir_group"), getvar("settings.${prefix}dirs.${base_dir}.group"), getvar('settings.config_dir_group'), undef)
$real_recurse = pick_default(getvar("settings.${base_dir}_dir_recurse"), getvar("settings.${prefix}dirs.${base_dir}.recurse"), getvar('settings.config__dir_recurse'), undef)
Expand Down Expand Up @@ -314,7 +314,7 @@
notify => $real_notify,
recurse => $real_recurse,
purge => $real_purge,
# force => $real_force,
# force => $real_force,
}
file { $real_path:
* => $file_params + pick(getvar("settings.${base_dir}_dir_params"),getvar("settings.${prefix}dirs.${base_dir}.params"), {}),
Expand Down
6 changes: 3 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
String $tp_group = 'root',
String $tp_mode = '0755',
String $check_service_command = 'puppet resource service',
String $check_service_command_post = '',
String $check_service_command_post = '', # lint:ignore:params_empty_string_assignment
String $check_package_command = 'puppet resource package',
String $check_repo_path = '',
String $check_repo_path_post = '',
String $check_repo_path = '', # lint:ignore:params_empty_string_assignment
String $check_repo_path_post = '', # lint:ignore:params_empty_string_assignment
#Stdlib::Absolutepath $tp_dir = '/etc/tp',
Optional[String] $ruby_path = undef,
String $lib_source = 'puppet:///modules/tp/lib/',
Expand Down
32 changes: 15 additions & 17 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
Hash $tp_repo_params = {},
Boolean $manage_package = true,
Boolean $manage_service = true,
Boolean $apt_safe_trusted_key = lookup('tp::apt_safe_trusted_key', Boolean , first, false),
Boolean $apt_safe_trusted_key = pick(getvar('tp::apt_safe_trusted_key'), false),

Boolean $cli_enable = pick(getvar('tp::cli_enable'), false),
Boolean $puppi_enable = false,
Expand Down Expand Up @@ -239,11 +239,11 @@
$extracted_file = getvar('tp_settings.release.extracted_file')

$local_settings = delete_undef_values({
install_method => $real_install_method,
repo => $repo,
upstream_repo => $upstream_repo,
install_method => getvar('real_install_method'),
repo => getvar('repo'),
upstream_repo => getvar('upstream_repo'),
git_source => $real_install_method ? {
'source' => $source,
'source' => getvar('source'),
default => undef,
},
destination => $real_install_method ? {
Expand All @@ -252,20 +252,18 @@
default => undef,
},
packages => delete_undef_values({
main => delete_undef_values({
name => tp::title_replace(getvar('settings.packages.main.name'),$app),
}),
}),
release => delete_undef_values({
base_url => pick_default($real_base_url),
file_name => $real_filename,
url => $real_url,
extracted_dir => $extracted_dir,
extracted_file => $extracted_file,
setup => delete_undef_values({
enable => getvar('tp_settings.release.setup.enable'),
links => getvar('tp_settings.release.setup.links'),
}),
base_url => getvar('real_base_url'),
file_name => getvar('real_filename'),
url => getvar('real_url'),
extracted_dir => getvar('extracted_dir'),
extracted_file => getvar('extracted_file'),
setup => delete_undef_values({
enable => getvar('tp_settings.release.setup.enable'),
links => getvar('tp_settings.release.setup.links'),
}),
}),
})

Expand All @@ -289,7 +287,7 @@
tp::setup { "tp::install::${real_install_method} ${app}":
ensure => $ensure,
version => $real_version,
install_method => $real_install_method,
install_method => $real_install_method,
source_dir => getvar('settings.destination'),
app => $app,
on_missing_data => $on_missing_data,
Expand Down
4 changes: 2 additions & 2 deletions manifests/install/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
Hash $tp_repo_params = {},
Boolean $manage_package = true,
Boolean $manage_service = true,
Boolean $apt_safe_trusted_key = lookup('tp::apt_safe_trusted_key', Boolean , first, false),
Boolean $apt_safe_trusted_key = pick(getvar('tp::apt_safe_trusted_key'), false),

String[1] $data_module = 'tinydata',

Expand Down Expand Up @@ -345,7 +345,7 @@
}
$services.each |$k| {
service { $k:
* => $service_defaults + pick(getvar("settings.services.${kk}.params"), getvar('settings.service_params'), {}),
* => $service_defaults + pick(getvar("settings.services.${k}.params"), getvar('settings.service_params'), {}),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Variant[Undef,String[1]] $apt_release = undef,
Variant[Undef,String[1]] $apt_repos = undef,
Variant[Undef,String[1]] $apt_pin = undef,
Boolean $apt_safe_trusted_key = lookup('tp::apt_safe_trusted_key', Boolean , first, false),
Boolean $apt_safe_trusted_key = pick(getvar('tp::apt_safe_trusted_key'), false),
Stdlib::Absolutepath $apt_gpg_key_dir = '/etc/apt/keyrings',

Variant[Undef,String[1]] $zypper_repofile_url = undef,
Expand Down
2 changes: 1 addition & 1 deletion manifests/setup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# tp::setup { 'namevar': }
define tp::setup (
Tp::Install_method $install_method,
Optional[StdLib::Absolutepath] $source_dir,
String $app,
Optional[StdLib::Absolutepath] $source_dir = undef,
Variant[Boolean,String] $ensure = present,
Optional[String] $version = undef,
Tp::Fail $on_missing_data = pick(getvar('tp::on_missing_data'),'notify'),
Expand Down
Loading
Loading