Skip to content

Commit

Permalink
Merge pull request #231 from ripienaar/229.1
Browse files Browse the repository at this point in the history
(#229) avoid duplicate resources
  • Loading branch information
ripienaar authored Aug 18, 2019
2 parents 05917e0 + f428883 commit a2a09df
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions manifests/module_plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,27 @@
Optional[String] $owner = $mcollective::plugin_owner,
Optional[String] $group = $mcollective::plugin_group,
Optional[String] $mode = $mcollective::plugin_mode,
Enum["present", "absent"] $ensure = "present"
Boolean $activate_agent = true
Enum["present", "absent"] $ensure = "present",
Boolean $activate_agent = true,
Boolean $activate_client = true
) {
$_agent = $name =~ /^mcollective_agent_/

if $client or $server {
if ($server and $client) {
$activate_config = {"activate_agent" => $activate_agent, "activate_client" => $activate_client}
$activate_config = $_agent ? {true => {"activate_agent" => $activate_agent, "activate_client" => $activate_client}, false => {}}
$merged_conf = $config.deep_merge($client_config).deep_merge($server_config) + $activate_config
$merged_files = $common_files + $server_files + $client_files
$merged_directories = $common_directories + $server_directories + $client_directories

} elsif ($server) {
$activate_config = {"activate_agent" => $activate_agent, "activate_client" => false}
$activate_config = $_agent ? {true => {"activate_agent" => $activate_agent, "activate_client" => false}, false => {}}
$merged_conf = $config.deep_merge($server_config) + $activate_config
$merged_files = $common_files + $server_files
$merged_directories = $common_directories + $server_directories

} elsif ($client) {
$activate_config = {"activate_agent" => false, "activate_client" => $activate_client}
$activate_config = $_agent ? {true => {"activate_agent" => false, "activate_client" => $activate_client}, false => {}}
$merged_conf = $config.deep_merge($client_config) + $activate_config
$merged_files = $common_files + $client_files
$merged_directories = $common_directories + $client_directories
Expand Down Expand Up @@ -94,12 +96,17 @@
}

unless $merged_conf.empty {
mcollective::config_file { "${configdir}/plugin.d/${config_name}.cfg":
ensure => $ensure,
settings => $merged_conf,
owner => $owner,
group => $group,
mode => $mode
# the bolt agent and main choria coded both use choria as plugin name which breaks this
# we have to fix that when moving to the new model for distributing plugins for now
# this is the only way
unless defined(Mcollective::Config_file["${configdir}/plugin.d/${config_name}.cfg"]) {
mcollective::config_file{"${configdir}/plugin.d/${config_name}.cfg":
ensure => $ensure,
settings => $merged_conf,
owner => $owner,
group => $group,
mode => $mode
}
}
}

Expand Down

0 comments on commit a2a09df

Please sign in to comment.