Skip to content

Commit

Permalink
lint fixes and params validation
Browse files Browse the repository at this point in the history
  • Loading branch information
alvagante committed Sep 24, 2024
1 parent 83b2fd2 commit 179b67a
Show file tree
Hide file tree
Showing 44 changed files with 1,058 additions and 1,166 deletions.
1 change: 1 addition & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--relative
--ignore-lint-parameter_documentation
15 changes: 7 additions & 8 deletions manifests/check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# :include:../README.check
#
define puppi::check (
$command,
$base_dir = '',
$hostwide = 'no',
$priority = '50',
$project = 'default',
$enable = true ) {

String $command,
String $base_dir = '',
String $hostwide = 'no',
Variant[String,Integer] $priority = '50',
String $project = 'default',
Boolean $enable = true,
) {
require puppi
require puppi::params

Expand All @@ -46,5 +46,4 @@
content => "${real_base_dir}/${command}\n",
tag => 'puppi_check',
}

}
16 changes: 7 additions & 9 deletions manifests/configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# :include:../README.deploy
#
define puppi::configure (
$command,
$project,
$arguments = '',
$priority = '50',
$user = 'root',
$enable = true ) {

String $command,
String $project,
String $arguments = '',
Variant[String,Integer] $priority = '50',
String $user = 'root',
Boolean $enable = true,
) {
require puppi
require puppi::params

Expand All @@ -35,6 +35,4 @@
content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n",
tag => 'puppi_deploy',
}

}

2 changes: 0 additions & 2 deletions manifests/dependencies.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# install_dependencies => false
#
class puppi::dependencies {

require puppi::params

if ! defined(Package['curl']) {
Expand All @@ -34,5 +33,4 @@
if ! defined(Package[$puppi::params::package_mail]) {
package { $puppi::params::package_mail : ensure => present }
}

}
16 changes: 7 additions & 9 deletions manifests/deploy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# :include:../README.deploy
#
define puppi::deploy (
$command,
$project,
$arguments = '',
$priority = '50',
$user = 'root',
$enable = true ) {

String $command,
String $project,
String $arguments = '',
Variant[String,Integer] $priority = '50',
String $user = 'root',
Boolean $enable = true,
) {
require puppi
require puppi::params

Expand All @@ -35,6 +35,4 @@
content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n",
tag => 'puppi_deploy',
}

}

51 changes: 23 additions & 28 deletions manifests/extras.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# extra_class=> 'example42::puppi::extras',
#
class puppi::extras {

# Default Checks

puppi::check { 'NTP_Sync':
Expand Down Expand Up @@ -52,64 +51,63 @@
hostwide => 'yes' ,
}


# Info Pages
$network_run = $::os['name'] ? {
'Solaris' => [ 'ifconfig -a' , 'netstat -nr' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -na' ],
default => [ 'ifconfig' , 'route -n' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -natup | grep LISTEN' ],
$network_run = $facts['os']['name'] ? {
'Solaris' => ['ifconfig -a' , 'netstat -nr' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -na'],
default => ['ifconfig' , 'route -n' , 'cat /etc/resolv.conf' , 'arp -an' , 'netstat -natup | grep LISTEN'],
}

puppi::info { 'network':
description => 'Network settings and stats' ,
run => $network_run,
}

$users_run = $::os['name'] ? {
'Solaris' => [ 'who' , 'last' ],
default => [ 'who' , 'last' , 'LANG=C lastlog | grep -v \'Never logged in\'' ],
$users_run = $facts['os']['name'] ? {
'Solaris' => ['who' , 'last'],
default => ['who' , 'last' , 'LANG=C lastlog | grep -v \'Never logged in\''],
}

puppi::info { 'users':
description => 'Users and logins information' ,
run => $users_run,
}

$perf_run = $::os['name'] ? {
'Solaris' => [ 'uptime' , 'vmstat 1 5' ],
default => [ 'uptime' , 'free' , 'vmstat 1 5' ],
$perf_run = $facts['os']['name'] ? {
'Solaris' => ['uptime' , 'vmstat 1 5'],
default => ['uptime' , 'free' , 'vmstat 1 5'],
}

puppi::info { 'perf':
description => 'System performances and resources utilization' ,
run => $perf_run,
}

$disks_run = $::os['name'] ? {
'Solaris' => [ 'df -h' , 'mount' ],
default => [ 'df -h' , 'mount' , 'blkid' , 'fdisk -l' ],
$disks_run = $facts['os']['name'] ? {
'Solaris' => ['df -h' , 'mount'],
default => ['df -h' , 'mount' , 'blkid' , 'fdisk -l'],
}

puppi::info { 'disks':
description => 'Disks and filesystem information' ,
run => $disks_run,
}

$hardware_run = $::os['name'] ? {
'Solaris' => [ 'find /devices/' ],
default => [ 'lspci' , 'cat /proc/cpuinfo' ],
$hardware_run = $facts['os']['name'] ? {
'Solaris' => ['find /devices/'],
default => ['lspci' , 'cat /proc/cpuinfo'],
}

puppi::info { 'hardware':
description => 'Hardware information' ,
run => $hardware_run,
}

$packages_run = $::os['name'] ? {
/(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => [ 'yum repolist' , 'rpm -qa' ] ,
/(?i:Debian|Ubuntu|Mint)/ => [ 'apt-config dump' , 'apt-cache stats' , 'apt-key list' , 'dpkg -l' ],
/(Solaris)/ => [ 'pkginfo' ],
/(Archlinux)/ => [ 'pacman -Qet' ],
default => [ 'echo' ],
$packages_run = $facts['os']['name'] ? {
/(?i:RedHat|CentOS|Scientific|Amazon|Linux)/ => ['yum repolist' , 'rpm -qa'],
/(?i:Debian|Ubuntu|Mint)/ => ['apt-config dump' , 'apt-cache stats' , 'apt-key list' , 'dpkg -l'],
/(Solaris)/ => ['pkginfo'],
/(Archlinux)/ => ['pacman -Qet'],
default => ['echo'],
}

puppi::info { 'packages':
Expand All @@ -128,8 +126,7 @@
}

### Default Logs
case $::os['family'] {

case $facts['os']['family'] {
'Debian': {
puppi::log { 'system':
description => 'General System Messages',
Expand Down Expand Up @@ -201,8 +198,6 @@
}
}

default: { }

default: {}
}

}
7 changes: 3 additions & 4 deletions manifests/helper.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# }
#
define puppi::helper (
$template,
$ensure = 'present' ) {

String $template,
String $ensure = 'present',
) {
require puppi
require puppi::params

Expand All @@ -25,5 +25,4 @@
group => $puppi::params::configfile_group,
content => template($template),
}

}
2 changes: 0 additions & 2 deletions manifests/helpers.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
# Automatically included by Puppi
#
class puppi::helpers {

# Standard helper for Example42 modules
puppi::helper { 'standard':
template => 'puppi/helpers/standard.yml.erb',
}

}
11 changes: 5 additions & 6 deletions manifests/info.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
# :include:../README.info
#
define puppi::info (
$description = '',
$templatefile = 'puppi/info.erb',
$run = '' ) {

String $description = '',
String $templatefile = 'puppi/info.erb',
String $run = '',
) {
require puppi
require puppi::params

Expand All @@ -34,13 +34,12 @@
}

file { "${puppi::params::infodir}/${name}":
ensure => present,
ensure => file,
mode => '0750',
owner => $puppi::params::configfile_owner,
group => $puppi::params::configfile_group,
require => Class['puppi'],
content => template($templatefile),
tag => 'puppi_info',
}

}
33 changes: 16 additions & 17 deletions manifests/info/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@
# This is a puppi info plugin specific for the tomcat::instance define
#
define puppi::info::instance (
$servicename = '',
$processname = '',
$configdir = '',
$bindir = '',
$pidfile = '',
$datadir = '',
$logdir = '',
$httpport = '',
$controlport = '',
$ajpport = '',
$description = '',
$run = '',
$verbose = 'no',
$templatefile = 'puppi/info/instance.erb' ) {

String $servicename = '',
String $processname = '',
String $configdir = '',
String $bindir = '',
String $pidfile = '',
String $datadir = '',
String $logdir = '',
Variant[String,Integer] $httpport = '',
Variant[String,Integer] $controlport = '',
Variant[String,Integer] $ajpport = '',
String $description = '',
String $run = '',
String $verbose = 'no',
String $templatefile = 'puppi/info/instance.erb',
) {
require puppi
require puppi::params

file { "${puppi::params::infodir}/${name}":
ensure => present,
ensure => file,
mode => '0750',
owner => $puppi::params::configfile_owner,
group => $puppi::params::configfile_group,
content => template($templatefile),
tag => 'puppi_info',
}

}
37 changes: 18 additions & 19 deletions manifests/info/module.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,33 @@
# }
#
define puppi::info::module (
$packagename = '',
$servicename = '',
$processname = '',
$configfile = '',
$configdir = '',
$initconfigfile = '',
$pidfile = '',
$datadir = '',
$logfile = '',
$logdir = '',
$protocol = '',
$port = '',
$description = '',
$run = '',
$verbose = 'no',
$templatefile = 'puppi/info/module.erb' ) {

String $packagename = '',
String $servicename = '',
String $processname = '',
String $configfile = '',
String $configdir = '',
String $initconfigfile = '',
String $pidfile = '',
String $datadir = '',
String $logfile = '',
String $logdir = '',
String $protocol = '',
Variant[String,Integer] $port = '',
String $description = '',
String $run = '',
String $verbose = 'no',
String $templatefile = 'puppi/info/module.erb',
) {
require puppi
require puppi::params

file { "${puppi::params::infodir}/${name}":
ensure => present,
ensure => file,
mode => '0750',
owner => $puppi::params::configfile_owner,
group => $puppi::params::configfile_group,
require => Class['puppi'],
content => template($templatefile),
tag => 'puppi_info',
}

}
Loading

0 comments on commit 179b67a

Please sign in to comment.