Skip to content

Commit

Permalink
Allow Setting Ca file mode (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
roock authored and pcfens committed Sep 14, 2017
1 parent e4222b9 commit 3d7f3c8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions manifests/ca.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
# source. (defaults to true)
# [*checksum*]
# The md5sum of the file. (defaults to undef)
# [*ca_file_mode*]
# The installed CA certificate's POSIX filesystem permissions. This uses
# the same syntax as Puppet's native file resource's "mode" parameter.
# (defaults to '0444', i.e. world-readable)
#
# === Examples
#
Expand All @@ -35,6 +39,7 @@
$ensure = 'trusted',
$verify_https_cert = true,
$checksum = undef,
$ca_file_mode = $ca_cert::params::ca_file_mode,
) {

include ::ca_cert::params
Expand Down Expand Up @@ -91,6 +96,7 @@
path => $ca_cert,
owner => 'root',
group => 'root',
mode => $ca_file_mode,
require => Package[$ca_cert::params::package_name],
notify => Class['::ca_cert::update'],
}
Expand All @@ -114,6 +120,7 @@
path => $ca_cert,
owner => 'root',
group => 'root',
mode => $ca_file_mode,
require => Package[$ca_cert::params::package_name],
notify => Class['::ca_cert::update'],
}
Expand All @@ -125,6 +132,7 @@
path => $ca_cert,
owner => 'root',
group => 'root',
mode => $ca_file_mode,
require => Package[$ca_cert::params::package_name],
notify => Class['::ca_cert::update'],
}
Expand Down
4 changes: 3 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@
}

$trusted_cert_dir = $ca_cert::params::trusted_cert_dir
$cert_dir_group = $ca_cert::params::cert_dir_group
$cert_dir_group = $ca_cert::params::cert_dir_group
$cert_dir_mode = $ca_cert::params::cert_dir_mode

file { 'trusted_certs':
ensure => directory,
path => $trusted_cert_dir,
owner => 'root',
group => $cert_dir_group,
mode => $cert_dir_mode,
purge => $purge_unmanaged_CAs,
recurse => $purge_unmanaged_CAs,
notify => Exec['ca_cert_update'],
Expand Down
18 changes: 18 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@
$trusted_cert_dir = '/usr/local/share/ca-certificates'
$update_cmd = 'update-ca-certificates'
$cert_dir_group = 'staff'
$ca_file_mode = '0444'
$ca_file_extension = 'crt'
$package_name = 'ca-certificates'
case $::operatingsystem {
'Ubuntu': {
$cert_dir_mode = '0755'
}
'Debian': {
$cert_dir_mode = '2665'
}
default: {
fail("Unsupported operatingsystem (${::operatingsystem})")
}
}
}
'RedHat': {
$trusted_cert_dir = '/etc/pki/ca-trust/source/anchors'
$distrusted_cert_dir = '/etc/pki/ca-trust/source/blacklist'
$update_cmd = 'update-ca-trust extract'
$cert_dir_group = 'root'
$cert_dir_mode = '0555'
$ca_file_mode = '0444'
$ca_file_extension = 'crt'
$package_name = 'ca-certificates'
}
Expand All @@ -21,6 +35,8 @@
$distrusted_cert_dir = '/etc/ca-certificates/trust-source/blacklist'
$update_cmd = 'trust extract-compat'
$cert_dir_group = 'root'
$cert_dir_mode = '0555'
$ca_file_mode = '0444'
$ca_file_extension = 'crt'
$package_name = 'ca-certificates'
}
Expand All @@ -39,6 +55,8 @@
$package_name = 'ca-certificates'
}
$cert_dir_group = 'root'
$cert_dir_mode = '0555'
$ca_file_mode = '0444'
}
default: {
fail("Unsupported osfamily (${::osfamily})")
Expand Down
1 change: 1 addition & 0 deletions spec/classes/ca_cert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
}
end

Expand Down
1 change: 1 addition & 0 deletions spec/classes/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu'
}
end

Expand Down

0 comments on commit 3d7f3c8

Please sign in to comment.