Skip to content

Commit

Permalink
Better handling for the config_directory parameter.
Browse files Browse the repository at this point in the history
As suggested by @smortex.
  • Loading branch information
NiklausHofer committed Sep 21, 2021
1 parent 2048705 commit 4af2f25
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ prosody::user: prosody
prosody::virtualhost_defaults: {}
prosody::virtualhosts: {}

prosody::config::config_directory: '/etc/prosody'
prosody::config_directory: '/etc/prosody'

prosody::community_modules::ensure: present
prosody::community_modules::path: /var/lib/prosody/modules
Expand Down
2 changes: 1 addition & 1 deletion data/os/Gentoo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prosody::info_log: /var/log/jabber/prosody.log
prosody::pidfile: /run/jabber/prosody.pid
prosody::user: jabber

prosody::config::config_directory: '/etc/jabber'
prosody::config_directory: '/etc/jabber'

prosody::community_modules::ensure: present
prosody::community_modules::path: /usr/lib64/prosody/community-modules
Expand Down
10 changes: 4 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# == Class: prosody::config
class prosody::config (
Stdlib::Absolutepath $config_directory,
) {
file { "${config_directory}/conf.avail":
class prosody::config {
file { "${prosody::config_directory}/conf.avail":
ensure => directory,
}

file { "${config_directory}/conf.d":
file { "${prosody::config_directory}/conf.d":
ensure => directory,
}

file { "${config_directory}/prosody.cfg.lua":
file { "${prosody::config_directory}/prosody.cfg.lua":
content => template('prosody/prosody.cfg.erb'),
require => Class['prosody::package'],
notify => Class['prosody::service'],
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
Optional[Stdlib::Absolutepath] $ssl_cert = undef,
Optional[Stdlib::Absolutepath] $ssl_key = undef,
Optional[String] $ssl_protocol = undef,
Optional[Stdlib::Absolutepath] $config_directory = undef,
) {
if ($community_modules != []) {
class { 'prosody::community_modules':
Expand Down
9 changes: 4 additions & 5 deletions manifests/virtualhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Optional[String] $group = undef,
Hash $components = {},
Array[String[1]] $disco_items = [],
Stdlib::Absolutepath $config_directory = lookup('prosody::config::config_directory'),
) {
# Check if SSL set correctly
if (($ssl_key != undef) and ($ssl_cert == undef)) {
Expand All @@ -21,8 +20,8 @@

if (($ssl_key != undef) and ($ssl_cert != undef) and ($ssl_copy == true)) {
# Copy the provided sources to prosody certs folder
$prosody_ssl_key = "${config_directory}/certs/${name}.key"
$prosody_ssl_cert = "${config_directory}/certs/${name}.crt"
$prosody_ssl_key = "${prosody::config_directory}/certs/${name}.key"
$prosody_ssl_cert = "${prosody::config_directory}/certs/${name}.crt"

$file_user = pick_default($user, 'prosody')
$file_group = pick_default($group, 'prosody')
Expand Down Expand Up @@ -54,7 +53,7 @@
$config_requires = Class['prosody::package']
}

$conf_avail_fn = "${config_directory}/conf.avail/${name}.cfg.lua"
$conf_avail_fn = "${prosody::config_directory}/conf.avail/${name}.cfg.lua"

file { $conf_avail_fn:
ensure => $ensure,
Expand All @@ -68,7 +67,7 @@
'absent' => absent,
}

file { "${config_directory}/conf.d/${name}.cfg.lua":
file { "${prosody::config_directory}/conf.d/${name}.cfg.lua":
ensure => $cfg_ensure,
target => $conf_avail_fn,
notify => Class['prosody::service'],
Expand Down

0 comments on commit 4af2f25

Please sign in to comment.