Skip to content

Commit

Permalink
Merge pull request #140 from smortex/windows
Browse files Browse the repository at this point in the history
(#145) First step of Windows support
  • Loading branch information
ripienaar authored Jan 4, 2020
2 parents 4b03028 + d385631 commit d02173c
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 34 deletions.
5 changes: 4 additions & 1 deletion data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ choria::server_config:
plugin.choria.agent_provider.mcorpc.libdir: "/opt/puppetlabs/mcollective/plugins"

choria::rubypath: "/opt/puppetlabs/puppet/bin/ruby"
choria::manage_package: true
choria::manage_service: true
choria::manage_package_repo: false
choria::nightly_repo: false
choria::repo_baseurl: "https://packagecloud.io/choria"
Expand All @@ -27,7 +29,8 @@ choria::broker_service_name: "choria-broker"
choria::server_service_name: "choria-server"
choria::identity: "%{trusted.certname}"
choria::server: false
choria::root_group: "root"
choria::config_user: "root"
choria::config_group: "root"

choria::broker::network_broker: true
choria::broker::federation_broker: false
Expand Down
2 changes: 1 addition & 1 deletion data/os/FreeBSD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ choria::server_config:
choria::rubypath: "/usr/local/bin/ruby"
choria::broker_config_file: "/usr/local/etc/choria/broker.conf"
choria::server_config_file: "/usr/local/etc/choria/server.conf"
choria::root_group: "wheel"
choria::config_group: "wheel"
choria::mcollective_config_dir: "/usr/local/etc/mcollective"
19 changes: 18 additions & 1 deletion data/os/windows.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
---
choria::mcollective_config_dir: "C:/ProgramData/PuppetLabs/mcollective/etc"
choria::server_config:
plugin.rpcaudit.logfile: "C:/ProgramData/choria/var/log/choria-audit.log"
classesfile: "C:/ProgramData/PuppetLabs/puppet/cache/state/classes.txt"
plugin.rpcaudit.logfile: "C:/ProgramData/choria/var/log/choria-audit.log"
plugin.yaml: "C:/ProgramData/choria/etc/generated-facts.yaml"
plugin.choria.agent_provider.mcorpc.agent_shim: "C:/Program Files/choria/bin/choria_mcollective_agent_compat.rb"
plugin.choria.agent_provider.mcorpc.config: "C:/ProgramData/choria/etc/choria-shim.cfg"
plugin.choria.agent_provider.mcorpc.libdir: "C:/ProgramData/choria/lib/plugins"
choria::rubypath: "C:/Program Files/Puppet Labs/Puppet/puppet/bin/ruby.exe"
choria::broker_config_file: "C:/ProgramData/choria/etc/broker.conf"
choria::server_config_file: "C:/ProgramData/choria/etc/server.conf"
choria::logfile: "C:/ProgramData/choria/var/log/choria.log"
choria::statusfile: "C:/ProgramData/choria/var/log/choria-status.json"
choria::manage_package: false
choria::manage_service: false
choria::mcollective_config_dir: "C:/ProgramData/choria/etc"
choria::config_user: ~
choria::config_group: ~
8 changes: 4 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@

if "plugin.choria.agent_provider.mcorpc.agent_shim" in $choria::server_config and "plugin.choria.agent_provider.mcorpc.config" in $choria::server_config {
file{$choria::server_config["plugin.choria.agent_provider.mcorpc.agent_shim"]:
owner => "root",
group => $choria::root_group,
owner => $choria::config_user,
group => $choria::config_group,
mode => "0755",
content => epp("choria/choria_mcollective_agent_compat.rb.epp")
}
}

file{$choria::server_config_file:
owner => "root",
group => $choria::root_group,
owner => $choria::config_user,
group => $choria::config_group,
mode => "0640",
content => choria::hash2config($config),
notify => Class["choria::service"],
Expand Down
7 changes: 6 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installs, configures and manages the Choria Orchestrator
#
# @param manage_package Manage the choria package
# @param manage_service Manage the choria-server package
# @param manage_package_repo Installs the package repositories
# @param nightly_repo Install the nightly package repo as well as the release one
# @param ensure Add or remove the software
Expand All @@ -25,6 +27,8 @@
# @param server To enable or disable the choria server
# @param server_config Configuration for the Choria Server
class choria (
Boolean $manage_package,
Boolean $manage_service,
Boolean $manage_package_repo ,
Boolean $nightly_repo,
Enum["present", "absent"] $ensure,
Expand All @@ -45,7 +49,8 @@
String $identity,
Boolean $server,
Hash $server_config,
String $root_group,
Optional[String] $config_user,
Optional[String] $config_group,
Enum[debug, info, warn, error, fatal] $broker_log_level = $log_level,
Enum[debug, info, warn, error, fatal] $server_log_level = $log_level,
Stdlib::Compat::Absolute_path $broker_logfile = $logfile,
Expand Down
14 changes: 8 additions & 6 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
class choria::install {
assert_private()

$version = $choria::ensure ? {
"present" => $choria::version,
"absent" => "absent"
}
if $choria::manage_package {
$version = $choria::ensure ? {
"present" => $choria::version,
"absent" => "absent"
}

package{$choria::package_name:
ensure => $version
package{$choria::package_name:
ensure => $version
}
}
}
42 changes: 22 additions & 20 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@
class choria::service {
assert_private()

if $choria::server {
service{$choria::server_service_name:
ensure => "running",
enable => true
}
if $choria::manage_service {
if $choria::server {
service{$choria::server_service_name:
ensure => "running",
enable => true
}

# Since the installation of mcollective plugins are handled in another module at
# the moment we have to do this ugly hackery here to ensure we restart choria
# service when new plugins are installed
#
# Eventually this module will own installation of plugins and things will improve
# for now its a bit meh
Service<| title == "mcollective" |> ~> Service[$choria::server_service_name]
# Since the installation of mcollective plugins are handled in another module at
# the moment we have to do this ugly hackery here to ensure we restart choria
# service when new plugins are installed
#
# Eventually this module will own installation of plugins and things will improve
# for now its a bit meh
Service<| title == "mcollective" |> ~> Service[$choria::server_service_name]

# Without this when a mcollective plugin is removed if purge is on the service
# would not be restarted, unfortunate side effect that a client uninstall will
# also yield a restart
File<| tag == "mcollective::plugin_dirs" |> ~> Service[$choria::server_service_name]
# Without this when a mcollective plugin is removed if purge is on the service
# would not be restarted, unfortunate side effect that a client uninstall will
# also yield a restart
File<| tag == "mcollective::plugin_dirs" |> ~> Service[$choria::server_service_name]

} else {
service{$choria::server_service_name:
ensure => "stopped",
enable => false
} else {
service{$choria::server_service_name:
ensure => "stopped",
enable => false
}
}
}
}

0 comments on commit d02173c

Please sign in to comment.