Skip to content

Commit

Permalink
(GH-cat-9) Update code to match syntax standard, part 1
Browse files Browse the repository at this point in the history
Code now compliant with the following rules:
- manifest_whitespace_closing_bracket_after
- relative_classname_inclusion
- relative_classname_reference
- version_conparison
- legacy_facts
- top_scope_facts
  • Loading branch information
david22swan committed Jun 6, 2022
1 parent 574d07e commit 08f7a48
Show file tree
Hide file tree
Showing 52 changed files with 227 additions and 176 deletions.
6 changes: 0 additions & 6 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
--relative
--no-parameter_types-check
--no-parameter_documentation-check
--no-top_scope_facts-check
--no-legacy_facts-check
--no-relative_classname_reference-check
--no-relative_classname_inclusion-check
--no-anchor_resource-check
--no-version_comparison-check
--no-manifest_whitespace_closing_bracket_after-check
7 changes: 0 additions & 7 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,4 @@ Rakefile:
extra_disabled_lint_checks:
- parameter_types
- parameter_documentation
- top_scope_facts
- legacy_facts
- relative_classname_reference
- relative_classname_inclusion
- anchor_resource
- version_comparison
- manifest_whitespace_closing_bracket_after

6 changes: 0 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ end
PuppetLint.configuration.send('disable_relative')
PuppetLint.configuration.send('disable_parameter_types')
PuppetLint.configuration.send('disable_parameter_documentation')
PuppetLint.configuration.send('disable_top_scope_facts')
PuppetLint.configuration.send('disable_legacy_facts')
PuppetLint.configuration.send('disable_relative_classname_reference')
PuppetLint.configuration.send('disable_relative_classname_inclusion')
PuppetLint.configuration.send('disable_anchor_resource')
PuppetLint.configuration.send('disable_version_comparison')
PuppetLint.configuration.send('disable_manifest_whitespace_closing_bracket_after')


if Bundler.rubygems.find_name('github_changelog_generator').any?
Expand Down
2 changes: 1 addition & 1 deletion manifests/balancermember.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#
define apache::balancermember (
$balancer_cluster,
$url = "http://${::fqdn}/",
$url = "http://${$facts['networking']['fqdn']}/",
$options = [],
) {
concat::fragment { "BalancerMember ${name}":
Expand Down
2 changes: 1 addition & 1 deletion manifests/default_confd_files.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
) {
# The rest of the conf.d/* files only get loaded if we want them
if $all {
case $::osfamily {
case $facts['os']['family'] {
'freebsd': {
include apache::confd::no_accf
}
Expand Down
10 changes: 5 additions & 5 deletions manifests/default_mods.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
# These are modules required to run the default configuration.
# They are not configurable at this time, so we just include
# them to make sure it works.
case $::osfamily {
case $facts['os']['family'] {
'redhat': {
::apache::mod { 'log_config': }
if versioncmp($apache_version, '2.4') >= 0 {
# Lets fork it
# Do not try to load mod_systemd on RHEL/CentOS 6 SCL.
if ( !($::osfamily == 'redhat' and versioncmp($::operatingsystemmajrelease, '7') == -1) and !($::operatingsystem == 'Amazon') ) {
if ( !($facts['os']['family'] == 'redhat' and versioncmp($facts['os']['release']['major'], '7') == -1) and !($facts['os']['name'] == 'Amazon') ) {
if ($use_systemd) {
::apache::mod { 'systemd': }
}
}
if ($::operatingsystem == 'Amazon' and $::operatingsystemrelease == '2') {
if ($facts['os']['name'] == 'Amazon' and $facts['os']['release']['full'] == '2') {
::apache::mod { 'systemd': }
}
::apache::mod { 'unixd': }
Expand All @@ -37,15 +37,15 @@
}
default: {}
}
case $::osfamily {
case $facts['os']['family'] {
'gentoo': {}
default: {
::apache::mod { 'authz_host': }
}
}
# The rest of the modules only get loaded if we want all modules enabled
if $all {
case $::osfamily {
case $facts['os']['family'] {
'debian': {
include apache::mod::authn_core
include apache::mod::reqtimeout
Expand Down
12 changes: 6 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,13 @@
$access_log_file = $apache::params::access_log_file,
Array[Enum['h2', 'h2c', 'http/1.1']] $protocols = [],
Optional[Boolean] $protocols_honor_order = undef,
) inherits ::apache::params {
) inherits apache::params {
$valid_mpms_re = $apache_version ? {
'2.4' => '(event|itk|peruser|prefork|worker)',
default => '(event|itk|prefork|worker)'
}

if $::osfamily == 'RedHat' and $facts['operatingsystemmajrelease'] == '7' {
if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '7' {
# On redhat 7 the ssl.conf lives in /etc/httpd/conf.d (the confd_dir)
# when all other module configs live in /etc/httpd/conf.modules.d (the
# mod_dir). On all other platforms and versions, ssl.conf lives in the
Expand All @@ -580,7 +580,7 @@
# should delete the 'if' block below and modify all MPM modules' manifests
# such that they include apache::package class (currently event.pp, itk.pp,
# peruser.pp, prefork.pp, worker.pp).
if $::osfamily != 'FreeBSD' {
if $facts['os']['family'] != 'FreeBSD' {
package { 'httpd':
ensure => $package_ensure,
name => $apache_name,
Expand Down Expand Up @@ -735,7 +735,7 @@
}

if $apache::conf_dir and $apache::params::conf_file {
if $::osfamily == 'gentoo' {
if $facts['os']['family'] == 'gentoo' {
$error_documents_path = '/usr/share/apache2/error'
if $default_mods =~ Array {
if defined('apache::mod::ssl') {
Expand All @@ -758,7 +758,7 @@
}
}

$apxs_workaround = $::osfamily ? {
$apxs_workaround = $facts['os']['family'] ? {
'freebsd' => true,
default => false
}
Expand Down Expand Up @@ -837,7 +837,7 @@
use_servername_for_filenames => true,
use_port_for_filenames => true,
}
$ssl_access_log_file = $::osfamily ? {
$ssl_access_log_file = $facts['os']['family'] ? {
'freebsd' => $access_log_file,
default => "ssl_${access_log_file}",
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/mod.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
if $package {
$_package = $package
} elsif has_key($mod_packages, $mod) { # 2.6 compatibility hack
if ($apache::apache_version == '2.4' and $::operatingsystem =~ /^[Aa]mazon$/ and $::operatingsystemmajrelease != '2') {
if ($apache::apache_version == '2.4' and $facts['os']['name'] =~ /^[Aa]mazon$/ and $facts['os']['release']['major'] != '2') {
# On amazon linux we need to prefix our package name with mod24 instead of mod to support apache 2.4
$_package = regsubst($mod_packages[$mod],'^(mod_)?(.*)','mod24_\2')
} else {
Expand All @@ -98,7 +98,7 @@
# httpd.conf with 'LoadModule' directives; here, by proper resource
# ordering, we ensure that our version of httpd.conf is reverted after
# the module gets installed.
$package_before = $::osfamily ? {
$package_before = $facts['os']['family'] ? {
'freebsd' => [
File[$_loadfile_name],
File["${apache::conf_dir}/${apache::params::conf_file}"]
Expand Down Expand Up @@ -134,7 +134,7 @@
notify => Class['apache::service'],
}

if $::osfamily == 'Debian' {
if $facts['os']['family'] == 'Debian' {
$enable_dir = $apache::mod_enable_dir
file { "${_loadfile_name} symlink":
ensure => link,
Expand Down Expand Up @@ -169,7 +169,7 @@
notify => Class['apache::service'],
}
}
} elsif $::osfamily == 'Suse' {
} elsif $facts['os']['family'] == 'Suse' {
$enable_dir = $apache::mod_enable_dir
file { "${_loadfile_name} symlink":
ensure => link,
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/alias.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# set icons_path to false to disable the alias
$icons_path = $apache::params::alias_icons_path,
$icons_prefix = $apache::params::icons_prefix
) inherits ::apache::params {
) inherits apache::params {
include apache
$_apache_version = pick($apache_version, $apache::apache_version)
apache::mod { 'alias': }
Expand Down
4 changes: 2 additions & 2 deletions manifests/mod/auth_cas.pp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
$cas_attribute_delimiter = undef,
$cas_scrub_request_headers = undef,
$suppress_warning = false,
) inherits ::apache::params {
if $::osfamily == 'RedHat' and ! $suppress_warning {
) inherits apache::params {
if $facts['os']['family'] == 'RedHat' and ! $suppress_warning {
warning('RedHat distributions do not have Apache mod_auth_cas in their default package repositories.')
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/auth_mellon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$mellon_post_ttl = undef,
$mellon_post_size = undef,
$mellon_post_count = undef
) inherits ::apache::params {
) inherits apache::params {
include apache
::apache::mod { 'auth_mellon': }

Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/auth_openidc.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# @see https://github.com/zmartzone/mod_auth_openidc for additional documentation.
#
class apache::mod::auth_openidc (
) inherits ::apache::params {
) inherits apache::params {
include apache
include apache::mod::authz_user
apache::mod { 'auth_openidc': }
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/authn_dbd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$authn_dbd_keep = '8',
$authn_dbd_exptime = '300',
$authn_dbd_alias = undef,
) inherits ::apache::params {
) inherits apache::params {
include apache
include apache::mod::dbd
::apache::mod { 'authn_dbd': }
Expand Down
4 changes: 2 additions & 2 deletions manifests/mod/autoindex.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#
class apache::mod::autoindex (
$icons_prefix = $apache::params::icons_prefix
) inherits ::apache::params {
) inherits apache::params {
include apache
::apache::mod { 'autoindex': }

# Determine icon filename suffix for autoindex.conf.erb
case $::operatingsystem {
case $facts['os']['name'] {
'Debian', 'Ubuntu': {
$icon_suffix = '-20x22'
}
Expand Down
14 changes: 7 additions & 7 deletions manifests/mod/cgi.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
#
class apache::mod::cgi {
include apache
case $::osfamily {
case $facts['os']['family'] {
'FreeBSD': {}
default: {
if defined(Class['::apache::mod::itk']) {
Class['::apache::mod::itk'] -> Class['::apache::mod::cgi']
} elsif defined(Class['::apache::mod::peruser']) {
Class['::apache::mod::peruser'] -> Class['::apache::mod::cgi']
if defined(Class['apache::mod::itk']) {
Class['apache::mod::itk'] -> Class['apache::mod::cgi']
} elsif defined(Class['apache::mod::peruser']) {
Class['apache::mod::peruser'] -> Class['apache::mod::cgi']
} else {
Class['::apache::mod::prefork'] -> Class['::apache::mod::cgi']
Class['apache::mod::prefork'] -> Class['apache::mod::cgi']
}
}
}

if $::osfamily == 'Suse' {
if $facts['os']['family'] == 'Suse' {
::apache::mod { 'cgi':
lib_path => '/usr/lib64/apache2-prefork',
}
Expand Down
12 changes: 6 additions & 6 deletions manifests/mod/cgid.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
#
class apache::mod::cgid {
include apache
case $::osfamily {
case $facts['os']['family'] {
'FreeBSD': {}
default: {
if defined(Class['::apache::mod::event']) {
Class['::apache::mod::event'] -> Class['::apache::mod::cgid']
if defined(Class['apache::mod::event']) {
Class['apache::mod::event'] -> Class['apache::mod::cgid']
} else {
Class['::apache::mod::worker'] -> Class['::apache::mod::cgid']
Class['apache::mod::worker'] -> Class['apache::mod::cgid']
}
}
}

# Debian specifies it's cgid sock path, but RedHat uses the default value
# with no config file
$cgisock_path = $::osfamily ? {
$cgisock_path = $facts['os']['family'] ? {
'debian' => "\${APACHE_RUN_DIR}/cgisock",
'freebsd' => 'cgisock',
default => undef,
}

if $::osfamily == 'Suse' {
if $facts['os']['family'] == 'Suse' {
::apache::mod { 'cgid':
lib_path => '/usr/lib64/apache2-worker',
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/mod/dav_fs.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#
class apache::mod::dav_fs {
include apache
$dav_lock = $::osfamily ? {
$dav_lock = $facts['os']['family'] ? {
'debian' => "\${APACHE_LOCK_DIR}/DAVLock",
'freebsd' => '/usr/local/var/DavLock',
default => '/var/lib/dav/lockdb',
}

Class['::apache::mod::dav'] -> Class['::apache::mod::dav_fs']
Class['apache::mod::dav'] -> Class['apache::mod::dav_fs']
::apache::mod { 'dav_fs': }

# Template uses: $dav_lock
Expand Down
4 changes: 2 additions & 2 deletions manifests/mod/dav_svn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
class apache::mod::dav_svn (
$authz_svn_enabled = false,
) {
Class['::apache::mod::dav'] -> Class['::apache::mod::dav_svn']
Class['apache::mod::dav'] -> Class['apache::mod::dav_svn']
include apache
include apache::mod::dav
if($::operatingsystem == 'SLES' and versioncmp($::operatingsystemmajrelease, '12') < 0) {
if($facts['os']['name'] == 'SLES' and versioncmp($facts['os']['release']['major'], '12') < 0) {
package { 'subversion-server':
ensure => 'installed',
provider => 'zypper',
Expand Down
6 changes: 3 additions & 3 deletions manifests/mod/disk_cache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
$_cache_root = $cache_root
}
elsif versioncmp($apache::apache_version, '2.4') >= 0 {
$_cache_root = $::osfamily ? {
$_cache_root = $facts['os']['family'] ? {
'debian' => '/var/cache/apache2/mod_cache_disk',
'redhat' => '/var/cache/httpd/proxy',
'freebsd' => '/var/cache/mod_cache_disk',
}
}
else {
$_cache_root = $::osfamily ? {
$_cache_root = $facts['os']['family'] ? {
'debian' => '/var/cache/apache2/mod_disk_cache',
'redhat' => '/var/cache/mod_proxy',
'freebsd' => '/var/cache/mod_disk_cache',
Expand All @@ -53,7 +53,7 @@
apache::mod { 'disk_cache': }
}

Class['::apache::mod::cache'] -> Class['::apache::mod::disk_cache']
Class['apache::mod::cache'] -> Class['apache::mod::disk_cache']

# Template uses $_cache_root
file { 'disk_cache.conf':
Expand Down
4 changes: 2 additions & 2 deletions manifests/mod/event.pp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
notify => Class['apache::service'],
}

case $::osfamily {
case $facts['os']['family'] {
'redhat': {
if versioncmp($_apache_version, '2.4') >= 0 {
apache::mpm { 'event':
Expand All @@ -118,7 +118,7 @@
}
}
default: {
fail("Unsupported osfamily ${::osfamily}")
fail("Unsupported osfamily ${$facts['os']['family']}")
}
}
}
2 changes: 1 addition & 1 deletion manifests/mod/fastcgi.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
class apache::mod::fastcgi {
include apache
if ($::osfamily == 'Redhat' and versioncmp($::operatingsystemmajrelease, '7') >= 0) {
if ($facts['os']['family'] == 'Redhat' and versioncmp($facts['os']['release']['major'], '7') >= 0) {
fail('mod_fastcgi is no longer supported on el7 and above.')
}
if ($facts['os']['name'] == 'Ubuntu') {
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/fcgid.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$options = {},
) {
include apache
if ($::osfamily == 'RedHat' and $::operatingsystemmajrelease >= '7') or $::osfamily == 'FreeBSD' {
if ($facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '7') >= 0) or $facts['os']['family'] == 'FreeBSD' {
$loadfile_name = 'unixd_fcgid.load'
$conf_name = 'unixd_fcgid.conf'
} else {
Expand Down

0 comments on commit 08f7a48

Please sign in to comment.