Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Puppet 4 #49

Merged
merged 4 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
527 changes: 491 additions & 36 deletions .rubocop.yml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ script:
matrix:
fast_finish: true
include:
- rvm: 2.1
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.2
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ group :test do
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'rubocop-rspec', :require => false
gem 'rspec-puppet-facts', :require => false
end

group :development do
Expand Down
153 changes: 45 additions & 108 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
# by the nfs server.
#
# [*idmapd_file*]
# String. It defines the location of th file with the idmapd settings.
# String. It defines the location of the file with the idmapd settings.
#
# [*defaults_file*]
# String. It defines the location of th file with the nfs settings.
# String. It defines the location of the file with the nfs settings.
#
# [*manage_packages*]
# Boolean. It defines if the packages should be managed through this module
Expand Down Expand Up @@ -162,114 +162,51 @@
#

class nfs(
$ensure = 'present',
$server_enabled = false,
$client_enabled = false,
$nfs_v4 = $::nfs::params::nfs_v4,
$nfs_v4_client = $::nfs::params::nfs_v4,
$exports_file = $::nfs::params::exports_file,
$idmapd_file = $::nfs::params::idmapd_file,
$defaults_file = $::nfs::params::defaults_file,
$manage_packages = true,
$server_packages = $::nfs::params::server_packages,
$server_package_ensure = 'installed',
$client_packages = $::nfs::params::client_packages,
$client_package_ensure = 'installed',
$manage_server_service = true,
$manage_server_servicehelper = true,
$manage_client_service = true,
$server_service_name = $::nfs::params::server_service_name,
$server_service_ensure = 'running',
$server_service_enable = true,
$server_service_hasrestart = $::nfs::params::server_service_hasrestart,
$server_service_hasstatus = $::nfs::params::server_service_hasstatus,
$server_service_restart_cmd = $::nfs::params::server_service_restart_cmd,
$server_nfsv4_servicehelper = $::nfs::params::server_nfsv4_servicehelper,
$client_services = $::nfs::params::client_services,
$client_nfsv4_services = $::nfs::params::client_nfsv4_services,
$client_services_hasrestart = $::nfs::params::client_services_hasrestart,
$client_services_hasstatus = $::nfs::params::client_services_hasstatus,
$client_idmapd_setting = $::nfs::params::client_idmapd_setting,
$client_nfs_fstype = $::nfs::params::client_nfs_fstype,
$client_nfs_options = $::nfs::params::client_nfs_options,
$client_nfsv4_fstype = $::nfs::params::client_nfsv4_fstype,
$client_nfsv4_options = $::nfs::params::client_nfsv4_options,
$nfs_v4_export_root = $::nfs::params::nfs_v4_export_root,
$nfs_v4_export_root_clients = $::nfs::params::nfs_v4_export_root_clients,
$nfs_v4_mount_root = $::nfs::params::nfs_v4_mount_root,
$nfs_v4_idmap_domain = $::nfs::params::nfs_v4_idmap_domain,
$nfs_v4_root_export_ensure = 'mounted',
$nfs_v4_root_export_mount = undef,
$nfs_v4_root_export_remounts = false,
$nfs_v4_root_export_atboot = false,
$nfs_v4_root_export_options = '_netdev',
$nfs_v4_root_export_bindmount = undef,
$nfs_v4_root_export_tag = undef,
Enum['present', 'absent', 'running', 'stopped', 'disabled'] $ensure = 'present',
Boolean $server_enabled = false,
Boolean $client_enabled = false,
Boolean $nfs_v4 = $::nfs::params::nfs_v4,
Boolean $nfs_v4_client = $::nfs::params::nfs_v4,
String $exports_file = $::nfs::params::exports_file,
String $idmapd_file = $::nfs::params::idmapd_file,
Optional[String] $defaults_file = $::nfs::params::defaults_file,
Boolean $manage_packages = true,
Array $server_packages = $::nfs::params::server_packages,
String $server_package_ensure = 'installed',
Array $client_packages = $::nfs::params::client_packages,
String $client_package_ensure = 'installed',
Boolean $manage_server_service = true,
Boolean $manage_server_servicehelper = true,
Boolean $manage_client_service = true,
String $server_service_name = $::nfs::params::server_service_name,
Enum['present', 'absent', 'running', 'stopped', 'disabled'] $server_service_ensure = 'running',
Boolean $server_service_enable = true,
Boolean $server_service_hasrestart = $::nfs::params::server_service_hasrestart,
Boolean $server_service_hasstatus = $::nfs::params::server_service_hasstatus,
Optional[String] $server_service_restart_cmd = $::nfs::params::server_service_restart_cmd,
Optional[String] $server_nfsv4_servicehelper = $::nfs::params::server_nfsv4_servicehelper,
$client_services = $::nfs::params::client_services,
$client_nfsv4_services = $::nfs::params::client_nfsv4_services,
Boolean $client_services_hasrestart = $::nfs::params::client_services_hasrestart,
Boolean $client_services_hasstatus = $::nfs::params::client_services_hasstatus,
Array[String] $client_idmapd_setting = $::nfs::params::client_idmapd_setting,
String $client_nfs_fstype = $::nfs::params::client_nfs_fstype,
String $client_nfs_options = $::nfs::params::client_nfs_options,
String $client_nfsv4_fstype = $::nfs::params::client_nfsv4_fstype,
String $client_nfsv4_options = $::nfs::params::client_nfsv4_options,
String $nfs_v4_export_root = $::nfs::params::nfs_v4_export_root,
String $nfs_v4_export_root_clients = $::nfs::params::nfs_v4_export_root_clients,
String $nfs_v4_mount_root = $::nfs::params::nfs_v4_mount_root,
String $nfs_v4_idmap_domain = $::nfs::params::nfs_v4_idmap_domain,
String $nfs_v4_root_export_ensure = 'mounted',
Optional[String] $nfs_v4_root_export_mount = undef,
Boolean $nfs_v4_root_export_remounts = false,
Boolean $nfs_v4_root_export_atboot = false,
String $nfs_v4_root_export_options = '_netdev',
Optional[String] $nfs_v4_root_export_bindmount = undef,
Optional[String] $nfs_v4_root_export_tag = undef,
) inherits nfs::params {

# validate all params

if ! ($ensure in [ 'present', 'absent', 'running', 'stopped', 'disabled' ]) {
fail("\"${$ensure}\" is not a valid ensure parameter value")
}

validate_bool($server_enabled)
validate_bool($client_enabled)
validate_bool($nfs_v4)
validate_bool($nfs_v4_client)
validate_string($exports_file)
validate_string($idmapd_file)
validate_string($defaults_file)
validate_bool($manage_packages)
validate_array($server_packages)
validate_string($server_package_ensure)
validate_array($client_packages)
validate_string($client_package_ensure)
validate_bool($manage_server_service)
validate_bool($manage_server_servicehelper)
validate_bool($manage_client_service)
validate_string($server_service_name)

if ! ($server_service_ensure in [ 'present', 'absent', 'running', 'stopped', 'disabled' ]) {
fail("\"${server_service_ensure}\" is not a valid ensure parameter value")
}

validate_bool($server_service_enable)
validate_bool($server_service_hasrestart)
validate_bool($server_service_hasstatus)
validate_string($server_service_restart_cmd)
validate_string($server_nfsv4_servicehelper)
validate_hash($client_services)
validate_hash($client_nfsv4_services)
validate_bool($client_services_hasrestart)
validate_bool($client_services_hasstatus)
validate_array($client_idmapd_setting)
validate_string($client_nfs_fstype)
validate_string($client_nfs_options)
validate_string($client_nfsv4_fstype)
validate_string($client_nfsv4_options)
validate_string($nfs_v4_export_root)
validate_string($nfs_v4_export_root_clients)
validate_string($nfs_v4_mount_root)
validate_string($nfs_v4_idmap_domain)
validate_string($nfs_v4_root_export_ensure)

if $nfs_v4_root_export_mount != undef {
validate_string($nfs_v4_root_export_mount)
}

validate_bool($nfs_v4_root_export_remounts)
validate_bool($nfs_v4_root_export_atboot)
validate_string($nfs_v4_root_export_options)

if $nfs_v4_root_export_bindmount != undef {
validate_string($nfs_v4_root_export_bindmount)
}

if $nfs_v4_root_export_tag != undef {
validate_string($nfs_v4_root_export_tag)
}

if $server_enabled {

if $server_nfsv4_servicehelper != undef {
Expand Down
6 changes: 1 addition & 5 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,9 @@
}
],
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 5.0.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
"version_requirement": ">= 4.6.1 < 5.0.0"
}
]
}
8 changes: 4 additions & 4 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
describe 'include nfs without params' do
context 'default parameters' do
let(:pp) { "class { 'nfs': }" }
it 'should apply without errors without params' do
it 'applies without errors without params' do
apply_manifest('include nfs', catch_failures: true)
end
end
Expand Down Expand Up @@ -48,11 +48,11 @@ class { '::nfs':
}
EOS

it 'should work with no errors based on the example' do
expect(apply_manifest(server_pp).exit_code).to_not eq(1)
it 'works with no errors based on the example' do
expect(apply_manifest(server_pp).exit_code).not_to eq(1)
end

it 'should run a second time without changes' do
it 'runs a second time without changes' do
expect(apply_manifest(server_pp).exit_code).to eq(0)
end

Expand Down
Loading