Skip to content

Commit

Permalink
More Puppet 8 compliance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alvagante committed Oct 22, 2023
1 parent 830767e commit c6d7f58
Show file tree
Hide file tree
Showing 38 changed files with 105 additions and 104 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

## Release 1.1.0

- More updates for Puppet 8 compatibility
- 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

## Release 1.0.4

Expand Down
4 changes: 2 additions & 2 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) {
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/bolt/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
Boolean $use_default_config_files_hash = true,
Hash $config_files_hash = {},

Optional[String] $bolt_yaml_template = 'psick/bolt/project/bolt.yaml.epp',
String $bolt_yaml_template = 'psick/bolt/project/bolt.yaml.epp',
Optional[String] $inventory_yaml_template = undef,
Hash $options_hash = {},

Expand Down
2 changes: 1 addition & 1 deletion manifests/dns/resolver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
noop($noop_value)
}

if $::virtual != 'docker' {
if $facts['virtual'] != 'docker' {
file { $resolver_path:
ensure => file,
content => template($resolver_template),
Expand Down
2 changes: 1 addition & 1 deletion manifests/firewall/simple_nat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# puppetlabs/firewall
#
class psick::firewall::simple_nat (
$source_net = "${facts['networking']['network']}/${facts['networking']['netmask']}",
String $source_net = "${facts['networking']['network']}/${facts['networking']['netmask']}",
Boolean $manage = $psick::manage,
Boolean $noop_manage = $psick::noop_manage,
Boolean $noop_value = $psick::noop_value,
Expand Down
6 changes: 3 additions & 3 deletions manifests/hostname.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
noop($noop_value)
}

case $::kernel {
case $facts['kernel'] {
'Linux': {
if $::virtual != 'docker' {
if $facts['virtual'] != 'docker' {
if $update_hostname {
file { '/etc/hostname':
ensure => file,
Expand All @@ -43,7 +43,7 @@
if $update_host_entry {
host { $host:
ensure => present,
host_aliases => $::networking['fqdn'],
host_aliases => $facts['networking']['fqdn'],
ip => $ip,
}
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
Boolean $auto_prereq = true,
Boolean $enable_firstrun = false,

Optional[Boolean] $noop_mode = lookup('noop_mode',Optional[Boolean],'first',undef),
Optional[Boolean] $noop_mode = lookup('noop_mode',Optional[Boolean],'first',undef), # lint:ignore:lookup_in_parameter
Boolean $noop_manage = false,
Boolean $noop_value = false,

Expand Down Expand Up @@ -225,7 +225,7 @@
$osfamily_resources_defaults = lookup('psick::osfamily_resources_defaults',Hash,$osfamily_resources_defaults_merge_behaviour, {})
$osfamily_resources.each |$k,$v| {
if $facts['os']['family'] == $k {
if has_key($osfamily_resources_defaults, $k) {
if $k in $osfamily_resources_defaults {
$os_defaults = $osfamily_resources_defaults[$k]
} else {
$os_defaults = {}
Expand Down
2 changes: 1 addition & 1 deletion manifests/kmod/module.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
String $module = $title,
Optional[String] $conf_source = undef,
Optional[String] $conf_content = undef,
Optional[Hash] $conf_options = {},
Hash $conf_options = {},
Boolean $boot_load_configure = true,
) {
if $conf_source or $conf_content {
Expand Down
2 changes: 1 addition & 1 deletion manifests/logs/rsyslog.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
source => $config_dir_source,
}

if $::os['family'] == 'RedHat' and $::os['release']['major'] == '7' {
if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '7' {
::tp::conf { 'rsyslog::20-default.conf':
ensure => $ensure,
template => 'psick/logs/rsyslog/20-default.erb',
Expand Down
36 changes: 18 additions & 18 deletions manifests/netinstall.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@
# An optional custom command to run after having extracted the file.
#
define psick::netinstall (
$url,
$destination_dir,
String $extracted_dir = '',
$retrieve_command = 'wget',
$retrieve_args = '',
$owner = 'root',
$group = 'root',
$timeout = '3600',
$work_dir = '/var/tmp',
$path = '/bin:/sbin:/usr/bin:/usr/sbin',
$extract_command = '',
$preextract_command = '',
$postextract_command = '',
$postextract_cwd = '',
$exec_env = [],
$creates = undef,
String $url,
Stdlib::Absolutepath $destination_dir,
Optional[String] $extracted_dir = undef,
String $retrieve_command = 'wget',
String $retrieve_args = '', # lint:ignore:params_empty_string_assignment
String $owner = 'root',
String $group = 'root',
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
Optional[Stdlib::Absolutepath] $postextract_cwd = undef,
Array $exec_env = [],
Optional[Stdlib::Absolutepath] $creates = undef,
) {
$source_filename = parse_url($url,'filename')
$source_filetype = parse_url($url,'filetype')
Expand All @@ -98,7 +98,7 @@
}

$real_extracted_dir = $extracted_dir ? {
'' => $real_extract_command ? {
undef => $real_extract_command ? {
/(^cp.*|^rsync.*)/ => $source_filename,
/(^tar -zxf*|^tar -jxf*)/ => regsubst($source_dirname,'.tar',''),
default => $source_dirname,
Expand All @@ -107,7 +107,7 @@
}

$real_postextract_cwd = $postextract_cwd ? {
'' => "${destination_dir}/${real_extracted_dir}",
undef => "${destination_dir}/${real_extracted_dir}",
default => $postextract_cwd,
}

Expand Down
6 changes: 3 additions & 3 deletions manifests/network.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}

if $hostname {
contain ::psick::network::hostname
contain psick::network::hostname
}

# Manage /etc/host.conf if $host_conf_template is set
Expand All @@ -121,7 +121,7 @@
default => template($host_conf_template),
}
file { '/etc/host.conf':
ensure => present,
ensure => file,
content => $host_conf_content,
notify => $manage_config_file_notify,
}
Expand All @@ -136,7 +136,7 @@
default => template($nsswitch_conf_template),
}
file { '/etc/nsswitch.conf':
ensure => present,
ensure => file,
content => $nsswitch_conf_content,
notify => $manage_config_file_notify,
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/network/hostname.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

if $facts['os']['family'] == 'RedHat' {
file { '/etc/sysconfig/network':
ensure => present,
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
Expand All @@ -38,7 +38,7 @@

if $facts['os']['family'] == 'Debian' {
file { '/etc/hostname':
ensure => present,
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
Expand All @@ -49,7 +49,7 @@

if $facts['os']['family'] == 'Suse' {
file { '/etc/HOSTNAME':
ensure => present,
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
Expand All @@ -64,7 +64,7 @@

if $facts['os']['family'] == 'Solaris' {
file { '/etc/nodename':
ensure => present,
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
Expand Down
8 changes: 4 additions & 4 deletions manifests/network/interface.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
define psick::network::interface (
Enum['present','absent'] $ensure = 'present',
Boolean $enable = true,
Boolean $use_netplan = lookup('psick::network::use_netplan',Boolean,first,false),
Boolean $use_netplan = lookup('psick::network::use_netplan',Boolean,first,false), # lint:ignore:lookup_in_parameter

String $template = "psick/network/interface/${facts['os']['family']}.epp",
Optional[String] $config_path = undef,
Expand Down Expand Up @@ -299,7 +299,7 @@
# Prerequisites
if $manage_prerequisites
and is_hash($extra_settings) {
if has_key($extra_settings,'VLAN_ID')
if 'VLAN_ID' in $extra_settings
and !defined(Package['vlan']) {
package { 'vlan':
ensure => 'present',
Expand All @@ -308,7 +308,7 @@
}
}
if $manage_prerequisites
and has_key($settings,'BRIDGE')
and 'BRIDGE' in $settings
and !defined(Package['bridge-utils']) {
package { 'bridge-utils':
ensure => 'present',
Expand All @@ -332,7 +332,7 @@
'Debian', 'Ubuntu', 'LinuxMint': {
# Prerequisites
if $manage_prerequisites
and has_key($settings,'vlan-raw-device')
and 'vlan-raw-device' in $settings
and versioncmp('9.0', $facts['os']['release']['major']) >= 0
and !defined(Package['vlan']) {
package { 'vlan':
Expand Down
6 changes: 3 additions & 3 deletions manifests/network/netplan.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
Hash $tunnels = {},
Hash $vlans = {},

Optional[String] $file_content = undef,
Optional[String] $file_source = undef,
Optional[String] $file_content = undef,
Optional[String] $file_source = undef,

) {
$netplan_data = {
Expand All @@ -31,7 +31,7 @@
'bonds' => $bonds,
'tunnels' => $tunnels,
'vlans' => $vlans,
}
},
}

$real_file_content = $file_source ? {
Expand Down
4 changes: 2 additions & 2 deletions manifests/network/netplan/interface.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Hash $interface_options = {},

Stdlib::Absolutepath $config_dir_path = '/etc/netplan',
Optional[String] $reload_command = 'netplan apply',
Optional[String] $reload_command = 'netplan apply', # lint:ignore:optional_default

String $renderer = 'networkd',
Numeric $version = 2,
Expand All @@ -38,7 +38,7 @@
exec { 'psick::network::netplan::interface reload':
command => $reload_command,
refreshonly => true,
path => $::path
path => $facts['path'],
}
}
pick_default($reload_command, $psick::network::manage_config_file_notify)
Expand Down
4 changes: 2 additions & 2 deletions manifests/network/route.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
# Deploys the file /etc/sysconfig/network/ifroute-$name.
#
define psick::network::route (
Optional[Hash] $routes = {},
Optional[Hash] $ipv6_routes = {},
Hash $routes = {},
Hash $ipv6_routes = {},
String $interface = $title,
Variant[Undef,Resource,String] $config_file_notify = 'class_default',
Enum['present','absent'] $ensure = 'present',
Expand Down
4 changes: 2 additions & 2 deletions manifests/network/routing_table.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#
define psick::network::routing_table (
String $table_id,
String $table = $name
) {
String $table = $name,
) {
if ! defined(Concat['/etc/iproute2/rt_tables']) {
concat { '/etc/iproute2/rt_tables':
owner => 'root',
Expand Down
6 changes: 3 additions & 3 deletions manifests/network/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
case $facts['os']['family'] {
'RedHat': {
file { "rule-${interface}":
ensure => present,
ensure => file,
owner => root,
group => root,
mode => '0644',
Expand All @@ -40,7 +40,7 @@
notify => $psick::network::manage_config_file_notify,
}
file { "rule6-${interface}":
ensure => present,
ensure => file,
owner => root,
group => root,
mode => '0644',
Expand All @@ -51,7 +51,7 @@
}
'Suse': {
file { "ifrule-${interface}":
ensure => present,
ensure => file,
owner => root,
group => root,
mode => '0644',
Expand Down
3 changes: 1 addition & 2 deletions manifests/network/validate_gw.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# GWs validator. We need it to have compatibility with puppet 3.x, 'cause it doesn't support each.
#
define psick::network::validate_gw ($routes) {
define psick::network::validate_gw (Any $routes) {
$route = $routes[$name]
validate_string($route)
}
2 changes: 1 addition & 1 deletion manifests/nodejs.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
checksum_type => 'none',
cleanup => false,
before => Package[$package_name],
notify => Exec['nodejs setup']
notify => Exec['nodejs setup'],
}
$setup_script_default_params = {
command => "/bin/bash ${setup_script_path} > njs_setup.txt",
Expand Down
Loading

0 comments on commit c6d7f58

Please sign in to comment.