Skip to content

Commit

Permalink
Puppet >= 4 validations
Browse files Browse the repository at this point in the history
  • Loading branch information
edestecd committed Aug 26, 2020
1 parent c3cf761 commit eafda97
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ appveyor.yml:

.travis.yml:
user: edestecd
secure: "JWjiBcix532wh5nWMxIXj9aIVzJyMZLuL5kN5bRfwY4iJkWQ4VdTKbu9jHN7QRT7/BSmVzypeGQkLuPDgPWhFJp01577u0/4ruVJTlHHuNrfgFKFiBcI0L4ezHurX9kHRmr3pNOQioVT+bg+R8yYsZU92R8Pfyt1y1XB2XANhSe2m+mS44e4oM6QtRgElemKsIPlVDHh1jn4f2DYIuxacY/xiGfTJ7klRXOKh1d6jSlIRMEYynARTD9RggW2m79zPSzoId841tBIziZsx3nxXtmjmQ55CZb95US8Mw2UDCVywu6FS6lqkyForFqAYZ6nvwSteMHN8wwv8FAMPDUppuTvQzdTMSvohlRhzMn4bHFTpCKssikDemz/8AYK7kbIfRChgf30dZIlePH6MKXRgqj6JkkeB1//pDFqYge8u16w4e8l/OKJwBC2CvAralpqsrGx748+bkmPHIj2OYQb9rVV51aFVWDQ/eKsAd1L71FrjBG2XNduNxXcltMeNviUO7df2cB5BSsxu02KBhkR0tmVjqNIO1w9NRiDX3YbyavPBSEnn/Lx1j3ujVsG2uVzbMfvkMyi8kaP65gn+F5Ys8bvJKUad3GgswpezalNMMH7/WzLsEszhOI7zsCioyZxjd4LB+H9N0ji1naVFN0ut0XtOa5RYKkzcDBtFiVesxI="
secure: "xKK5tOeYwSISdni3byK/dp+Y5i7hhJqjGCZzm20+33dYb5tumtpAZOM/csC3NRhOZ6bR+q+SvnWtcjuzrQgXPYBHSW3AjmMEM1WO+HkNZ+61ze6drn5qBEMxtHphGxz1MGIXULgKAMFawGrhTP/YDnN9YkhCShgv/9OIa0P9ldki8dcn5EqliFpHYnLYhM7x2Uu8pbUmq4I590L89BFUYXJ1J7xmExmfluFw7Z2PfSA9tkBwOqbbeBMCVkZNQRzcfx30P9+vq+cMLAaQyNqYbbFptOm+qLuDO0fQCZrhyIqeXOy+soZYmIPTkQedeHoxfc8//UjmEqfdGjSmju9uLiaqcphxo2pX3hEkeTdLwsUqAJshq14fQ/e+uNZHvqWdsS2kEKqHk336a8BzCcZ2719DMyeshZVRv1P6ZbvS/BOeWoFQPpuhZsv6TEy0mB8sNTX8x0SjbP9RIIXMc46z/n9WvzESyac0lo+uiOPYNOVdx/0Dp295y/tpEwxK7avzXRC9CIikmRvcZuTBlMHaZwrzSO+hq0cze6/559eDS02ki8CIV3g8Kudl99lZ4tg2CREnFKHcU2ZYZ60JA9YrsVvI0zRhKZXtQQhSTVrMO2GAOVG4qyj92lvBRb4zWZjd/4XBObEMGKNB/VAuFIc7JC+t6Syz3o6eMVktC5pD5s4="

Gemfile:
required:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ deploy:
provider: puppetforge
username: edestecd
password:
secure: "JWjiBcix532wh5nWMxIXj9aIVzJyMZLuL5kN5bRfwY4iJkWQ4VdTKbu9jHN7QRT7/BSmVzypeGQkLuPDgPWhFJp01577u0/4ruVJTlHHuNrfgFKFiBcI0L4ezHurX9kHRmr3pNOQioVT+bg+R8yYsZU92R8Pfyt1y1XB2XANhSe2m+mS44e4oM6QtRgElemKsIPlVDHh1jn4f2DYIuxacY/xiGfTJ7klRXOKh1d6jSlIRMEYynARTD9RggW2m79zPSzoId841tBIziZsx3nxXtmjmQ55CZb95US8Mw2UDCVywu6FS6lqkyForFqAYZ6nvwSteMHN8wwv8FAMPDUppuTvQzdTMSvohlRhzMn4bHFTpCKssikDemz/8AYK7kbIfRChgf30dZIlePH6MKXRgqj6JkkeB1//pDFqYge8u16w4e8l/OKJwBC2CvAralpqsrGx748+bkmPHIj2OYQb9rVV51aFVWDQ/eKsAd1L71FrjBG2XNduNxXcltMeNviUO7df2cB5BSsxu02KBhkR0tmVjqNIO1w9NRiDX3YbyavPBSEnn/Lx1j3ujVsG2uVzbMfvkMyi8kaP65gn+F5Ys8bvJKUad3GgswpezalNMMH7/WzLsEszhOI7zsCioyZxjd4LB+H9N0ji1naVFN0ut0XtOa5RYKkzcDBtFiVesxI="
secure: "xKK5tOeYwSISdni3byK/dp+Y5i7hhJqjGCZzm20+33dYb5tumtpAZOM/csC3NRhOZ6bR+q+SvnWtcjuzrQgXPYBHSW3AjmMEM1WO+HkNZ+61ze6drn5qBEMxtHphGxz1MGIXULgKAMFawGrhTP/YDnN9YkhCShgv/9OIa0P9ldki8dcn5EqliFpHYnLYhM7x2Uu8pbUmq4I590L89BFUYXJ1J7xmExmfluFw7Z2PfSA9tkBwOqbbeBMCVkZNQRzcfx30P9+vq+cMLAaQyNqYbbFptOm+qLuDO0fQCZrhyIqeXOy+soZYmIPTkQedeHoxfc8//UjmEqfdGjSmju9uLiaqcphxo2pX3hEkeTdLwsUqAJshq14fQ/e+uNZHvqWdsS2kEKqHk336a8BzCcZ2719DMyeshZVRv1P6ZbvS/BOeWoFQPpuhZsv6TEy0mB8sNTX8x0SjbP9RIIXMc46z/n9WvzESyac0lo+uiOPYNOVdx/0Dp295y/tpEwxK7avzXRC9CIikmRvcZuTBlMHaZwrzSO+hq0cze6/559eDS02ki8CIV3g8Kudl99lZ4tg2CREnFKHcU2ZYZ60JA9YrsVvI0zRhKZXtQQhSTVrMO2GAOVG4qyj92lvBRb4zWZjd/4XBObEMGKNB/VAuFIc7JC+t6Syz3o6eMVktC5pD5s4="
on:
tags: true
all_branches: true
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## 2020-08-25 (2.0.0) Chris Edester
* PDK support at 1.18.0
* Puppet 5/6ish support
* Drop Puppet 3 support
* Update puppetlabs/stdlib dependency
* Switch to puppet/epel dependency

## 2016-08-10 (1.0.0) Chris Edester
* WARNING: Major revision, will most likely change your configs, especially on RedHat (Please test first)
* Refactor private class params and specs
Expand Down
84 changes: 27 additions & 57 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@
#

class clamav (
$manage_user = $clamav::params::manage_user,
$manage_repo = $clamav::params::manage_repo,
$manage_clamd = $clamav::params::manage_clamd,
$manage_freshclam = $clamav::params::manage_freshclam,
$manage_clamav_milter = $clamav::params::manage_clamav_milter,
$clamav_package = $clamav::params::clamav_package,
$clamav_version = $clamav::params::clamav_version,
Boolean $manage_user = $clamav::params::manage_user,
Boolean $manage_repo = $clamav::params::manage_repo,
Boolean $manage_clamd = $clamav::params::manage_clamd,
Boolean $manage_freshclam = $clamav::params::manage_freshclam,
Boolean $manage_clamav_milter = $clamav::params::manage_clamav_milter,
String $clamav_package = $clamav::params::clamav_package,
String $clamav_version = $clamav::params::clamav_version,

$user = $clamav::params::user,
$comment = $clamav::params::comment,
Optional[String] $comment = $clamav::params::comment,
$uid = $clamav::params::uid,
$gid = $clamav::params::gid,
$home = $clamav::params::home,
$shell = $clamav::params::shell,
Stdlib::Absolutepath $home = $clamav::params::home,
Stdlib::Absolutepath $shell = $clamav::params::shell,
$group = $clamav::params::group,
$groups = $clamav::params::groups,

$clamd_package = $clamav::params::clamd_package,
$clamd_version = $clamav::params::clamd_version,
$clamd_config = $clamav::params::clamd_config,
$clamd_service = $clamav::params::clamd_service,
String $clamd_package = $clamav::params::clamd_package,
String $clamd_version = $clamav::params::clamd_version,
Stdlib::Absolutepath $clamd_config = $clamav::params::clamd_config,
String $clamd_service = $clamav::params::clamd_service,
$clamd_service_ensure = $clamav::params::clamd_service_ensure,
$clamd_service_enable = $clamav::params::clamd_service_enable,
$clamd_options = $clamav::params::clamd_options,
Boolean $clamd_service_enable = $clamav::params::clamd_service_enable,
Hash $clamd_options = $clamav::params::clamd_options,

$freshclam_package = $clamav::params::freshclam_package,
$freshclam_version = $clamav::params::freshclam_version,
$freshclam_config = $clamav::params::freshclam_config,
Stdlib::Absolutepath $freshclam_config = $clamav::params::freshclam_config,
$freshclam_service = $clamav::params::freshclam_service,
$freshclam_service_ensure = $clamav::params::freshclam_service_ensure,
$freshclam_service_enable = $clamav::params::freshclam_service_enable,
$freshclam_options = $clamav::params::freshclam_options,
$freshclam_sysconfig = $clamav::params::freshclam_sysconfig,
$freshclam_delay = $clamav::params::freshclam_delay,
Boolean $freshclam_service_enable = $clamav::params::freshclam_service_enable,
Hash $freshclam_options = $clamav::params::freshclam_options,
Optional[Stdlib::Absolutepath] $freshclam_sysconfig = $clamav::params::freshclam_sysconfig,
Optional[String] $freshclam_delay = $clamav::params::freshclam_delay,

$clamav_milter_package = $clamav::params::clamav_milter_package,
$clamav_milter_version = $clamav::params::clamav_milter_version,
Expand All @@ -51,50 +51,20 @@
$clamav_milter_options = $clamav::params::clamav_milter_options,
) inherits clamav::params {

# Input validation
$valid_service_statuses = '^(stopped|false|running|true)$'

validate_bool($manage_user, $manage_repo, $manage_clamd, $manage_freshclam, $manage_clamav_milter)
validate_string($clamav_package)
validate_string($clamav_version)

# user
validate_string($comment)
validate_absolute_path($home)
validate_absolute_path($shell)

# clamd
validate_string($clamd_package)
validate_string($clamd_version)
validate_absolute_path($clamd_config)
validate_string($clamd_service)
validate_re($clamd_service_ensure, $valid_service_statuses)
validate_bool($clamd_service_enable)
validate_hash($clamd_options)
$_clamd_options = merge($clamav::params::clamd_default_options, $clamd_options)

# freshclam
validate_absolute_path($freshclam_config)
validate_re($freshclam_service_ensure, $valid_service_statuses)
validate_bool($freshclam_service_enable)
validate_hash($freshclam_options)
$_freshclam_options = merge($clamav::params::freshclam_default_options, $freshclam_options)
if $freshclam_sysconfig {
validate_absolute_path($freshclam_sysconfig)
}
if $freshclam_delay {
validate_string($freshclam_delay)
}

# clamav_milter
if $manage_clamav_milter {
validate_string($clamav_milter_package)
validate_string($clamav_milter_version)
validate_absolute_path($clamav_milter_config)
validate_string($clamav_milter_service)
validate_re($clamav_milter_service_ensure, $valid_service_statuses)
validate_bool($clamav_milter_service_enable)
validate_hash($clamav_milter_options)
assert_type(String, $clamav_milter_package)
assert_type(String, $clamav_milter_version)
assert_type(Stdlib::Absolutepath, $clamav_milter_config)
assert_type(String, $clamav_milter_service)
assert_type(Boolean, $clamav_milter_service_enable)
assert_type(Hash, $clamav_milter_options)
$_clamav_milter_options = merge($clamav::params::clamav_milter_default_options, $clamav_milter_options)
}

Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edestecd-clamav",
"version": "1.0.0",
"version": "2.0.0",
"author": "Chris Edester",
"summary": "Puppet Module for managing ClamAV",
"license": "GPL-3.0+",
Expand All @@ -10,7 +10,7 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.1.0 < 7.0.0"
"version_requirement": ">= 4.13.0 < 7.0.0"
},
{
"name": "puppet/epel",
Expand Down
8 changes: 8 additions & 0 deletions spec/classes/clamav_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
it { is_expected.to contain_class('clamav::freshclam') }
end

context 'manage manage_clamav_milter' do
if facts[:osfamily] == 'RedHat' && facts[:operatingsystemrelease] >= '7.0'
let(:params) { { manage_clamav_milter: true } }

it { is_expected.to contain_class('clamav::clamav_milter') }
end
end

context 'clamav::user' do
let(:params) { { manage_user: true } }

Expand Down

0 comments on commit eafda97

Please sign in to comment.