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

Add puppet8 / data types support #38

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
35 changes: 22 additions & 13 deletions manifests/appdefaults.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,35 @@
# Copyright 2013 Patrick Mooney.
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#

define mit_krb5::appdefaults(
$debug = '',
$ticket_lifetime = '',
$renew_lifetime = '',
$forwardable = '',
$krb4_convert = '',
$ignore_afs = '',
# @param debug
#
# @param ticket_lifetime
#
# @param renew_lifetime
#
# @param forwardable
#
# @param krb4_convert
#
# @param ignore_afs
#
define mit_krb5::appdefaults (
Optional[String] $debug = undef,
Optional[String] $ticket_lifetime = undef,
Optional[String] $renew_lifetime = undef,
Optional[String] $forwardable = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure backward compatibility, I think that we should introduce a new data type Mit_krb5::Bool_or_str such as:

type Mit_krb5::Bool_or_str = Variant[Boolean, Enum['true', 'false']]

Once introduced, $forwadable should be of type Optional[Mit_krb5::Bool_or_str]

Optional[String] $krb4_convert = undef,
Optional[String] $ignore_afs = undef,
) {
include mit_krb5
ensure_resource('concat::fragment', 'mit_krb5::appdefaults_header', {
target => $mit_krb5::krb5_conf_path,
order => '50appdefauls_header',
content => "\n[appdefaults]",
target => $mit_krb5::krb5_conf_path,
order => '50appdefauls_header',
content => "\n[appdefaults]",
})
concat::fragment { "mit_krb5::appdefaults::${title}":
target => $mit_krb5::krb5_conf_path,
order => "51appdefault-${title}",
content => template('mit_krb5/appdefaults.erb'),
}
}


2 changes: 1 addition & 1 deletion manifests/capaths.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
# Copyright 2013 Patrick Mooney.
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#
define mit_krb5::capaths() {
define mit_krb5::capaths () {
fail('PLACEHOLDER: Not yet implemented')
}
5 changes: 2 additions & 3 deletions manifests/config/etc_services.pp
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#
class mit_krb5::config::etc_services {

$protocols = {
'tcp' => 88,
'udp' => 88,
}

::etc_services { 'kerberos':
protocols => $protocols,
aliases => [ 'kerberos5', 'krb5', 'kerberos-sec' ],
comment => 'Kerberos v5'
aliases => ['kerberos5', 'krb5', 'kerberos-sec'],
comment => 'Kerberos v5',
}
}

Expand Down
38 changes: 19 additions & 19 deletions manifests/dbmodules.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,31 @@
# Copyright 2016 Modestas Vainius.
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#
define mit_krb5::dbmodules(
String $realm = $title,
$database_name = '',
$db_library = '',
$disable_last_success = '',
$disable_lockout = '',
$ldap_cert_path = '',
$ldap_conns_per_server = '',
$ldap_kadmind_dn = '',
$ldap_kdc_dn = '',
$ldap_kerberos_container_dn = '',
$ldap_servers = '',
$ldap_service_password_file = '',
define mit_krb5::dbmodules (
String $realm = $title,
Optional[String] $database_name = undef,
Optional[String] $db_library = undef,
Optional[Boolean] $disable_last_success = undef,
Optional[Boolean] $disable_lockout = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mit_krb5::Bool_or_str should be used to ensure backward compatibility

Optional[String] $ldap_cert_path = undef,
Optional[String] $ldap_conns_per_server = undef,
Optional[String] $ldap_kadmind_dn = undef,
Optional[String] $ldap_kdc_dn = undef,
Optional[String] $ldap_kerberos_container_dn = undef,
Optional[String] $ldap_servers = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a Array[String]

Optional[String] $ldap_service_password_file = undef,
) {
include mit_krb5
ensure_resource('concat::fragment', 'mit_krb5::dbmodules_header', {
target => $mit_krb5::krb5_conf_path,
order => '30dbmodules_header',
content => "\n[dbmodules]\n",
target => $mit_krb5::krb5_conf_path,
order => '30dbmodules_header',
content => "\n[dbmodules]\n",
})
if (! empty($mit_krb5::db_module_dir)) {
ensure_resource('concat::fragment', 'mit_krb5::dbmodules_db_module_dir', {
target => $mit_krb5::krb5_conf_path,
order => '31dbmodules_db_module_dir',
content => " db_module_dir = ${mit_krb5::db_module_dir}\n",
target => $mit_krb5::krb5_conf_path,
order => '31dbmodules_db_module_dir',
content => " db_module_dir = ${mit_krb5::db_module_dir}\n",
})
}
concat::fragment { "mit_krb5::dbmodules::${realm}":
Expand Down
16 changes: 8 additions & 8 deletions manifests/domain_realm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@
# Copyright 2013 Patrick Mooney.
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#
define mit_krb5::domain_realm(
define mit_krb5::domain_realm (
Array[String] $domains,
String $realm = $title,
) {
include ::mit_krb5
include mit_krb5

if count($domains) > 0 {
ensure_resource('concat::fragment', 'mit_krb5::domain_realm_header', {
target => $mit_krb5::krb5_conf_path,
order => '20domain_realm_header',
content => "[domain_realm]\n",
target => $mit_krb5::krb5_conf_path,
order => '20domain_realm_header',
content => "[domain_realm]\n",
})
concat::fragment { "mit_krb5::domain_realm::${title}":
target => $mit_krb5::krb5_conf_path,
order => "21realm_${realm}_${title}",
content => template('mit_krb5/domain_realm.erb'),
}
ensure_resource('concat::fragment', 'mit_krb5::domain_realm_trailer', {
target => $mit_krb5::krb5_conf_path,
order => '22domain_realm_trailer',
content => "\n",
target => $mit_krb5::krb5_conf_path,
order => '22domain_realm_trailer',
content => "\n",
})
}
}
132 changes: 71 additions & 61 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@
# [*krb5_conf_mode*]
# File mode for krb5.conf. (Default: 0444)
#
# [*alter_etc_services*]
#
# [*domain_realms*]
#
# [*capaths*]
#
# [*appdefaults*]
#
# [*realms*]
#
# [*dbmodules*]
#
# [*krb5_conf_warn*]
#
# === Examples
#
# class { 'mit_krb5':
Expand All @@ -241,57 +255,57 @@
# Copyright 2013 Patrick Mooney.
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#
class mit_krb5(
String $default_realm = '',
String $default_keytab_name = '',
$default_tgs_enctypes = [],
$default_tkt_enctypes = [],
String $default_ccache_name = '',
$permitted_enctypes = [],
$allow_weak_crypto = '',
String $clockskew = '',
$ignore_acceptor_hostname = '',
$k5login_authoritative = '',
String $k5login_directory = '',
String $kdc_timesync = '',
String $kdc_req_checksum_type = '',
String $ap_req_checksum_type = '',
String $safe_checksum_type = '',
String $preferred_preauth_types = '',
String $ccache_type = '',
$canonicalize = '',
$dns_canonicalize_hostname = '',
$dns_lookup_kdc = '',
$dns_lookup_realm = '',
$dns_fallback = '',
String $realm_try_domains = '',
$extra_addresses = [],
String $udp_preference_limit = '',
$verify_ap_req_nofail = '',
String $ticket_lifetime = '',
String $renew_lifetime = '',
$noaddresses = '',
$forwardable = '',
$proxiable = '',
$rdns = '',
$pkinit_anchors = '',
$spake_preauth_groups = '',
String $plugin_base_dir = '',
$include = '',
$includedir = '',
$module = '',
String $db_module_dir = '',
String $krb5_conf_path = '/etc/krb5.conf',
String $krb5_conf_owner = 'root',
String $krb5_conf_group = 'root',
String $krb5_conf_mode = '0444',
Boolean $alter_etc_services = false,
Boolean $krb5_conf_warn = true,
Hash $domain_realms = {},
Hash $capaths = {},
Hash $appdefaults = {},
Hash $realms = {},
Hash $dbmodules = {}
class mit_krb5 (
Optional[String] $default_realm = undef,
Optional[String] $default_keytab_name = undef,
Array $default_tgs_enctypes = [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Array[String]

Array $default_tkt_enctypes = [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Array[String]

Optional[String] $default_ccache_name = undef,
Array $permitted_enctypes = [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Array[String]

Optional[Boolean] $allow_weak_crypto = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mit_krb5::Bool_or_str should be used to ensure backward compatibility

Optional[String] $clockskew = undef,
Optional[String] $ignore_acceptor_hostname = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[String] $k5login_authoritative = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[String] $k5login_directory = undef,
Optional[String] $kdc_timesync = undef,
Optional[String] $kdc_req_checksum_type = undef,
Optional[String] $ap_req_checksum_type = undef,
Optional[String] $safe_checksum_type = undef,
Optional[String] $preferred_preauth_types = undef,
Optional[String] $ccache_type = undef,
Optional[String] $canonicalize = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[Boolean] $dns_canonicalize_hostname = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[Boolean] $dns_lookup_kdc = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[Boolean] $dns_lookup_realm = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[Boolean] $dns_fallback = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[String] $realm_try_domains = undef,
Array $extra_addresses = [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Array[Stdlib::IP::Address] .

Note to self: the current join logic used for extra_addresses is using space. krb5.conf(5) states that commas must be used.

Optional[String] $udp_preference_limit = undef,
Optional[Boolean] $verify_ap_req_nofail = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[String] $ticket_lifetime = undef,
Optional[String] $renew_lifetime = undef,
Optional[Boolean] $noaddresses = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[Boolean] $forwardable = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[Boolean] $proxiable = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Mit_krb5::Bool_or_str

Optional[Boolean] $rdns = undef,
flepoutre marked this conversation as resolved.
Show resolved Hide resolved
Optional[String] $pkinit_anchors = undef,
Optional[String] $spake_preauth_groups = undef,
Optional[String] $plugin_base_dir = undef,
Optional[String] $include = undef,
flepoutre marked this conversation as resolved.
Show resolved Hide resolved
Optional[String] $includedir = undef,
flepoutre marked this conversation as resolved.
Show resolved Hide resolved
Optional[String] $module = undef,
flepoutre marked this conversation as resolved.
Show resolved Hide resolved
Optional[String] $db_module_dir = undef,
String $krb5_conf_path = '/etc/krb5.conf',
String $krb5_conf_owner = 'root',
String $krb5_conf_group = 'root',
String $krb5_conf_mode = '0444',
Boolean $alter_etc_services = false,
Boolean $krb5_conf_warn = true,
Hash $domain_realms = {},
Hash $capaths = {},
Hash $appdefaults = {},
Hash $realms = {},
Hash $dbmodules = {},
) {
# SECTION: Parameter validation {
# Boolean-type parameters are not type-validated at this time.
Expand All @@ -305,21 +319,19 @@
# END Parameter validation }

# SECTION: Resource creation {
anchor { 'mit_krb5::begin': }

class { '::mit_krb5::install': }
contain 'mit_krb5::install'

if ($alter_etc_services == true) {
class { '::mit_krb5::config::etc_services':
require => Class['::mit_krb5::install']
class { 'mit_krb5::config::etc_services':
require => Class['mit_krb5::install'],
}
}

concat { $krb5_conf_path:
owner => $krb5_conf_owner,
group => $krb5_conf_group,
mode => $krb5_conf_mode,
warn => $krb5_conf_warn
warn => $krb5_conf_warn,
}
concat::fragment { 'mit_krb5::header':
target => $krb5_conf_path,
Expand All @@ -339,13 +351,11 @@
create_resources('mit_krb5::realm', $realms)
create_resources('mit_krb5::dbmodules', $dbmodules)

anchor { 'mit_krb5::end': }
# END Resource creation }

# SECTION: Resource ordering {
Anchor['mit_krb5::begin']
-> Class['mit_krb5::install']
contain 'mit_krb5::install'
Class['mit_krb5::install']
-> Concat[$krb5_conf_path]
-> Anchor['mit_krb5::end']
# END Resource ordering }
}
6 changes: 5 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
# Copyright 2013 Patrick Mooney.
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#
class mit_krb5::install($packages = undef) {
# @param packages
#
class mit_krb5::install (
Optional[String] $packages = undef,
flepoutre marked this conversation as resolved.
Show resolved Hide resolved
) {
if $packages {
if is_array($packages) {
$install = flatten($packages)
Expand Down
13 changes: 6 additions & 7 deletions manifests/logging.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@
# Copyright 2013 Patrick Mooney.
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
#
class mit_krb5::logging(
$default = '',
$admin_server = '',
$kdc = '',
$defaults = '',
class mit_krb5::logging (
Optional[String] $default = undef,
flepoutre marked this conversation as resolved.
Show resolved Hide resolved
Optional[String] $admin_server = undef,
Optional[String] $kdc = undef,
Optional[String] $defaults = undef,
) {

include ::mit_krb5
include mit_krb5

concat::fragment { 'mit_krb5::logging':
target => $mit_krb5::krb5_conf_path,
Expand Down
Loading