From e6812473fca371285df33cd28adaed081d6700c9 Mon Sep 17 00:00:00 2001 From: Alessandro Franceschi Date: Sun, 22 Oct 2023 10:29:14 +0200 Subject: [PATCH] More lints and Puppet8 fixes --- manifests/git/clone.pp | 2 +- manifests/netinstall.pp | 8 ++++---- manifests/network/interface.pp | 12 +++++------- manifests/puppet/autosign.pp | 2 +- manifests/puppet/pe_client_tools.pp | 2 +- manifests/puppet/pe_code_manager.pp | 10 +++++----- manifests/puppet/set_external_fact.pp | 2 +- manifests/python/fabric.pp | 2 +- manifests/python/pip.pp | 2 +- manifests/ruby.pp | 2 +- manifests/ruby/bundler.pp | 2 +- manifests/ruby/rbenv.pp | 8 ++++---- manifests/selinux.pp | 2 +- manifests/services.pp | 6 +++--- manifests/services/systemd_script.pp | 4 ++-- 15 files changed, 32 insertions(+), 34 deletions(-) diff --git a/manifests/git/clone.pp b/manifests/git/clone.pp index efbc29ed..7271accf 100644 --- a/manifests/git/clone.pp +++ b/manifests/git/clone.pp @@ -56,7 +56,7 @@ exec { "git_clone sync ${title}": command => $clone_sync, refreshonly => true, - path => $facts['path'], # This is the fact $::path + path => $facts['path'], # This is the fact $facts['path'] subscribe => [Tp::Dir["git_clone ${title}"], Exec["git_sync ${title}"]], user => $owner, } diff --git a/manifests/netinstall.pp b/manifests/netinstall.pp index 8c35d4aa..ef8e0ec7 100644 --- a/manifests/netinstall.pp +++ b/manifests/netinstall.pp @@ -68,9 +68,9 @@ Stdlib::Filemode $timeout = '3600', Stdlib::Absolutepath $work_dir = '/var/tmp', String $path = '/bin:/sbin:/usr/bin:/usr/sbin', - String $extract_command = '', # lint:ignore:params_empty_string_assignment - String $preextract_command = '', # lint:ignore:params_empty_string_assignment - String $postextract_command = '', # lint:ignore:params_empty_string_assignment + Variant[String,Boolean] $extract_command = '', # lint:ignore:params_empty_string_assignment + Variant[String,Boolean] $preextract_command = '', # lint:ignore:params_empty_string_assignment + Variant[String,Boolean] $postextract_command = '', # lint:ignore:params_empty_string_assignment Optional[Stdlib::Absolutepath] $postextract_cwd = undef, Array $exec_env = [], Optional[Stdlib::Absolutepath] $creates = undef, @@ -136,7 +136,7 @@ environment => $exec_env, } - if $extract_command { + if $real_extract_command and $real_extract_command != '' { exec { "Extract ${source_filename} from ${work_dir} - ${title}": command => "mkdir -p ${destination_dir} && cd ${destination_dir} && ${real_extract_command} ${work_dir}/${source_filename} ${extract_command_second_arg}", # lint:ignore:140chars unless => "ls ${destination_dir}/${real_extracted_dir}", diff --git a/manifests/network/interface.pp b/manifests/network/interface.pp index 25790799..17de245f 100644 --- a/manifests/network/interface.pp +++ b/manifests/network/interface.pp @@ -298,14 +298,12 @@ 'SLES', 'OpenSuSE': { # Prerequisites if $manage_prerequisites - and is_hash($extra_settings) { - if 'VLAN_ID' in $extra_settings - and !defined(Package['vlan']) { - package { 'vlan': - ensure => 'present', - } - Package['vlan'] -> File[$config_file_path] + and 'VLAN_ID' in $extra_settings + and !defined(Package['vlan']) { + package { 'vlan': + ensure => 'present', } + Package['vlan'] -> File[$config_file_path] } if $manage_prerequisites and 'BRIDGE' in $settings diff --git a/manifests/puppet/autosign.pp b/manifests/puppet/autosign.pp index ffd3b335..dad463ac 100644 --- a/manifests/puppet/autosign.pp +++ b/manifests/puppet/autosign.pp @@ -3,7 +3,7 @@ class psick::puppet::autosign ( Enum['on', 'off', 'policy_based'] $autosign = 'policy_based', Optional[String] $autosign_match = undef, - Optional[Array] $policy_based_psk = ['123456'], + Optional[Array] $policy_based_psk = undef, Boolean $manage = $psick::manage, Boolean $noop_manage = $psick::noop_manage, Boolean $noop_value = $psick::noop_value, diff --git a/manifests/puppet/pe_client_tools.pp b/manifests/puppet/pe_client_tools.pp index f2f415a0..001ed982 100644 --- a/manifests/puppet/pe_client_tools.pp +++ b/manifests/puppet/pe_client_tools.pp @@ -36,7 +36,7 @@ # Madness will be $pe_patch = $pe_short_version ? { - '21.5.0' => $::kernel ? { + '21.5.0' => $facts['kernel'] ? { 'windows' => '', default => '-1', }, diff --git a/manifests/puppet/pe_code_manager.pp b/manifests/puppet/pe_code_manager.pp index 3fdd2214..945c4d2d 100644 --- a/manifests/puppet/pe_code_manager.pp +++ b/manifests/puppet/pe_code_manager.pp @@ -8,13 +8,13 @@ Optional[String] $deploy_ssh_public_source = undef, Optional[String] $pe_user = undef, Optional[String] $pe_password = undef, - Optional[String] $pe_email = 'root@localhost', + String $pe_email = 'root@localhost', Optional[String] $deploy_comment = undef, - Optional[String] $deploy_user = 'root', - Optional[String] $puppet_user = 'pe-puppet', - Optional[String] $puppet_group = 'pe-puppet', + String $deploy_user = 'root', + String $puppet_user = 'pe-puppet', + String $puppet_group = 'pe-puppet', Optional[String] $puppet_user_home = undef, - Optional[String] $lifetime = '5y', + String $lifetime = '5y', Boolean $manage = $psick::manage, Boolean $noop_manage = $psick::noop_manage, Boolean $noop_value = $psick::noop_value, diff --git a/manifests/puppet/set_external_fact.pp b/manifests/puppet/set_external_fact.pp index 84fc5b7d..6099d643 100644 --- a/manifests/puppet/set_external_fact.pp +++ b/manifests/puppet/set_external_fact.pp @@ -15,7 +15,7 @@ fail('You must specify either a value or a template to use') } - $external_facts_dir = $::kernel ? { + $external_facts_dir = $facts['kernel'] ? { 'Windows' => 'C:\ProgramData\PuppetLabs\facter\facts.d', default => '/etc/puppetlabs/facter/facts.d', } diff --git a/manifests/python/fabric.pp b/manifests/python/fabric.pp index c3038af8..2425b7f4 100644 --- a/manifests/python/fabric.pp +++ b/manifests/python/fabric.pp @@ -1,7 +1,7 @@ # This class installs fabric # class psick::python::fabric ( - $ensure = 'present', + String $ensure = 'present', Boolean $manage = $psick::manage, Boolean $noop_manage = $psick::noop_manage, diff --git a/manifests/python/pip.pp b/manifests/python/pip.pp index fe8bb8e1..9828df4a 100644 --- a/manifests/python/pip.pp +++ b/manifests/python/pip.pp @@ -1,6 +1,6 @@ # class psick::python::pip ( - $ensure = 'present', + String $ensure = 'present', Boolean $manage = $psick::manage, Boolean $noop_manage = $psick::noop_manage, diff --git a/manifests/ruby.pp b/manifests/ruby.pp index d81ed58a..89130206 100644 --- a/manifests/ruby.pp +++ b/manifests/ruby.pp @@ -1,6 +1,6 @@ # class psick::ruby ( - $ensure = 'present', + String $ensure = 'present', Boolean $manage = $psick::manage, Boolean $noop_manage = $psick::noop_manage, diff --git a/manifests/ruby/bundler.pp b/manifests/ruby/bundler.pp index c108b957..32864a61 100644 --- a/manifests/ruby/bundler.pp +++ b/manifests/ruby/bundler.pp @@ -1,6 +1,6 @@ # class psick::ruby::bundler ( - $ensure = 'present', + String $ensure = 'present', Boolean $manage = $psick::manage, Boolean $noop_manage = $psick::noop_manage, diff --git a/manifests/ruby/rbenv.pp b/manifests/ruby/rbenv.pp index 8da79d1f..852a91bf 100644 --- a/manifests/ruby/rbenv.pp +++ b/manifests/ruby/rbenv.pp @@ -33,7 +33,7 @@ Variant[Boolean,String] $ensure = present, Enum['jdowning'] $module = 'jdowning', - Optional[String] $default_ruby_version = '2.4.2', + Optional[String] $default_ruby_version = undef, Optional[String] $install_dir = undef, Optional[String] $owner = undef, Optional[String] $group = undef, @@ -63,9 +63,9 @@ group => $group, latest => $latest, } - $default_gem_options = { - ruby_version => $default_ruby_version, - } + $default_gem_options = delete_undef_values({ + ruby_version => $default_ruby_version, + }) if $default_ruby_version and $auto_prereq { rbenv::plugin { 'rbenv/ruby-build': } rbenv::build { $default_ruby_version: diff --git a/manifests/selinux.pp b/manifests/selinux.pp index 1c08d860..7fe4e4dd 100644 --- a/manifests/selinux.pp +++ b/manifests/selinux.pp @@ -84,7 +84,7 @@ exec { 'psick_selinux_setenforce': command => "setenforce ${setenforce_status}", - path => $::path, + path => $facts['path'], refreshonly => true, } diff --git a/manifests/services.pp b/manifests/services.pp index d66a5706..5d6a7534 100644 --- a/manifests/services.pp +++ b/manifests/services.pp @@ -3,8 +3,8 @@ # This class provides a wrapper for psick services defines # class psick::services ( - Optional[Hash] $init_scripts = {}, - Optional[Hash] $systemd_scripts = {}, + Hash $init_scripts = {}, + Hash $systemd_scripts = {}, Boolean $manage = $psick::manage, Boolean $noop_manage = $psick::noop_manage, @@ -14,7 +14,7 @@ if $noop_manage { noop($noop_value) } - if $::kernel == 'Linux' { + if $facts['kernel'] == 'Linux' { $init_scripts.each |$k,$v| { psick::services::init_script { $k: * => $v, diff --git a/manifests/services/systemd_script.pp b/manifests/services/systemd_script.pp index 01315203..323320c9 100644 --- a/manifests/services/systemd_script.pp +++ b/manifests/services/systemd_script.pp @@ -9,11 +9,11 @@ Optional[String] $content = undef, Optional[String] $template = undef, Optional[String] $epp = undef, - Optional[String] $path = "/usr/local/sbin/${title}", + String $path = "/usr/local/sbin/${title}", Optional[String] $service_ensure = undef, Variant[Undef,Boolean,String] $service_enable = undef, String $systemd_template = 'psick/services/systemd.erb', - Optional[String] $systemd_after = 'network.target', + Optional[String] $systemd_after = 'network.target', # lint:ignore:optional_default Optional[String] $systemd_before = undef, ) { $manage_content = tp_content($content, $template, $epp)