Skip to content

Commit

Permalink
(#206) disable mcollectived on aio 6
Browse files Browse the repository at this point in the history
This adds a few bits to the mcollective fact that helps identify the
major version of AIO and Puppet and ensure its always created at least
in skeleton

It then uses this data to add a hiera tier for AIO Major version and
uses that tier to remove some of the bad conditionals that was added
earlier to branch on AIO 6

The settings for extra directories that AIO does not make has been moved
to OS specific hiera

AIO specific hiera disables mcollectived
  • Loading branch information
ripienaar committed Nov 27, 2018
1 parent a2f5ab3 commit 52105ba
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 31 deletions.
6 changes: 6 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ mcollective::libdir: "/opt/puppetlabs/mcollective/plugins"
mcollective::configdir: "/etc/puppetlabs/mcollective"
mcollective::rubypath: "/opt/puppetlabs/puppet/bin/ruby"
mcollective::gem_provider: "puppet_gem"
mcollective::manage_bin_symlinks: false
mcollective::plugintypes:
- "agent"
- "aggregate"
Expand All @@ -77,6 +78,11 @@ mcollective::plugintypes:
- "validator"
- "pluginpackager"

mcollective::required_directories:
- /etc/puppetlabs/mcollective
- /opt/puppetlabs/mcollective
- /opt/puppetlabs/mcollective/mcollective

lookup_options:
mcollective::collectives:
merge: "unique"
Expand Down
2 changes: 2 additions & 0 deletions data/os/Archlinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ mcollective::libdir: "/etc/puppetlabs/mcollective/plugins"
mcollective::rubypath: "/usr/bin/ruby"
mcollective::package_name: "mcollective"
mcollective::manage_package: true
mcollective::required_directories: []
mcollective::manage_bin_symlinks: false
1 change: 1 addition & 0 deletions data/os/Darwin.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mcollective::plugin_group: wheel
mcollective::required_directories: []
2 changes: 2 additions & 0 deletions data/os/FreeBSD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ mcollective::libdir: "/usr/local/share"
mcollective::rubypath: "/usr/local/bin/ruby"
mcollective::gem_provider: "gem"
mcollective::manage_package: true
mcollective::required_directories: []
mcollective::manage_bin_symlinks: false

mcollective::server_config:
classesfile: "/var/puppet/state/classes.txt"
Expand Down
2 changes: 2 additions & 0 deletions data/os/OpenBSD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ mcollective::libdir: "/usr/local/libexec/mcollective"
mcollective::rubypath: "/usr/local/bin/ruby24"
mcollective::gem_provider: "gem"
mcollective::manage_package: true
mcollective::required_directories: []
mcollective::manage_bin_symlinks: false

mcollective::server_config:
classesfile: "/var/puppetlabs/puppet/cache/state/classes.txt"
Expand Down
7 changes: 7 additions & 0 deletions data/os/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ mcollective::libdir: "C:/ProgramData/PuppetLabs/mcollective/plugins"
mcollective::configdir: "C:/ProgramData/PuppetLabs/mcollective/etc"
mcollective::rubypath: 'C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin\ruby.exe'
mcollective::facts_pidfile: ~
mcollective::manage_bin_symlinks: false

mcollective::required_directories:
- "C:/ProgramData/PuppetLabs/mcollective"
- "C:/ProgramData/PuppetLabs/mcollective/etc"
- "C:/ProgramData/PuppetLabs/mcollective/var"
- "C:/ProgramData/PuppetLabs/mcollective/var/log"

mcollective::server_config:
classesfile: "C:/ProgramData/PuppetLabs/puppet/cache/state/classes.txt"
Expand Down
3 changes: 3 additions & 0 deletions data/puppet_aio/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mcollective::service_ensure: stopped
mcollective::service_enable: false
mcollective::manage_bin_symlinks: true
4 changes: 4 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ defaults:
hierarchy:
- name: "OS family"
path: "os/%{facts.os.family}.yaml"

- name: "AIO version specific common"
path: "puppet_aio/%{facts.mcollective.aio_major_version}.yaml"

- name: "common"
path: "common.yaml"
23 changes: 16 additions & 7 deletions lib/facter/mcollective.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
Facter.add(:mcollective) do
pver = Facter.value(:puppetversion)
aiover = Facter.value(:aio_agent_version)

setcode do
result = {
"client" => {},
"server" => {},
"puppet_major_version" => 0,
"aio_major_version" => 0
}

result["puppet_major_version"] = pver.split(".").first.to_i if pver
result["aio_major_version"] = aiover.split(".").first.to_i if aiover

begin
require "mcollective"

result = {
"version" => MCollective::VERSION,
"client" => {},
"server" => {}
}

["client", "server"].each do |config|
if MCollective::Util.windows?
configfile = File.join(MCollective::Util.windows_prefix, "etc", "%s.cfg" % config)
Expand Down Expand Up @@ -40,7 +47,9 @@

result
rescue StandardError, LoadError
{"error" => "%s: %s" % [$!.class, $!.to_s]}
result["error"] = "%s: %s" % [$!.class, $!.to_s]
end

result
end
end
13 changes: 4 additions & 9 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
class mcollective::config {
if "aio_agent_version" in $facts and $facts["aio_agent_version"] =~ /^6/ {
# on windows we will need a bat file wrapper or something, anyway these
# hard coded paths would be different for now I'll just skip this till
# later
if $facts["os"]["family"] != "windows" {
file{"${mcollective::bindir}/mco":
ensure => link,
target => "/opt/puppetlabs/puppet/bin/mco",
}
if $mcollective::manage_bin_symlinks {
file{"${mcollective::bindir}/mco":
ensure => link,
target => "/opt/puppetlabs/puppet/bin/mco",
}
}

Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# @param plugin_owner The default user who will own plugin files
# @param plugin_group The default group who will own plugin files
# @param plugin_mode The default mode plugin files will have
# @param required_directories Any extra directories that should be created before copying plugins and configuration
# @param policy_default When managing plugin policies this will be the default allow/deny
# @param site_policies Policies to apply to all agents after any module specific policies
# @param rpcutil_policies Policies to apply to the special rpcutil agent
Expand All @@ -32,6 +33,7 @@
# @param server Install server files on this node
# @param purge When true will remove unmanaged files from the $configdir/plugin.d, $configdir/policies and $libdir
# @param gem_source where to find gems, useful for local gem mirrors
# @param manage_bin_symlinks Enables creating symlinks in the bin dir for the mco command
class mcollective (
Array[String] $plugintypes,
Array[String] $plugin_classes,
Expand All @@ -43,6 +45,7 @@
String $libdir,
String $configdir,
String $rubypath,
Boolean $manage_bin_symlinks = false,
Integer $facts_refresh_interval,
Array[Mcollective::Collective] $collectives,
Array[Mcollective::Collective] $client_collectives = $collectives,
Expand All @@ -52,6 +55,7 @@
Optional[String] $plugin_owner,
Optional[String] $plugin_group,
Optional[String] $plugin_mode,
Array[String] $required_directories = [],
Mcollective::Policy_action $policy_default,
Array[Mcollective::Policy] $site_policies = [],
Array[Mcollective::Policy] $rpcutil_policies = [],
Expand Down
12 changes: 1 addition & 11 deletions manifests/plugin_dirs.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@
"${mcollective::libdir}/mcollective/${type}"
}

if "aio_agent_version" in $facts and $facts["aio_agent_version"] =~ /^6/ {
$extra_dirs = [
"/etc/puppetlabs/mcollective",
"/opt/puppetlabs/mcollective",
"/opt/puppetlabs/mcollective/mcollective"
]
} else {
$extra_dirs = []
}

$needed_dirs = [
"${mcollective::configdir}/plugin.d",
"${mcollective::configdir}/policies",
$mcollective::libdir,
"${mcollective::libdir}/mcollective",
] + $libdirs + $extra_dirs
] + $libdirs + $mcollective::required_directories

if $mcollective::purge {
$purge_options = {
Expand Down
4 changes: 0 additions & 4 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
class mcollective::service {
if "aio_agent_version" in $facts and $facts["aio_agent_version"] =~ /^6/ {
return()
}

service{$mcollective::service_name:
ensure => $mcollective::service_ensure,
enable => $mcollective::service_enable
Expand Down

0 comments on commit 52105ba

Please sign in to comment.