From d385631626610b0706407db42ae67fbc1c7ef15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Fri, 22 Nov 2019 16:20:29 -1000 Subject: [PATCH] (misc) Add basic Windows support The goal here is to bring choria on Windows. For now, no packaged version of choria is available, and the software cannot run as a service, so the module will only configure the configuration files and does not manage the choria package and services itself. --- data/common.yaml | 5 ++++- data/os/FreeBSD.yaml | 2 +- data/os/windows.yaml | 19 ++++++++++++++++++- manifests/config.pp | 8 ++++---- manifests/init.pp | 7 ++++++- manifests/install.pp | 14 ++++++++------ manifests/service.pp | 42 ++++++++++++++++++++++-------------------- 7 files changed, 63 insertions(+), 34 deletions(-) diff --git a/data/common.yaml b/data/common.yaml index e52d55e..4735780 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -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" @@ -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 diff --git a/data/os/FreeBSD.yaml b/data/os/FreeBSD.yaml index 2eca162..88d60d2 100644 --- a/data/os/FreeBSD.yaml +++ b/data/os/FreeBSD.yaml @@ -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" diff --git a/data/os/windows.yaml b/data/os/windows.yaml index 9a52869..3657adf 100644 --- a/data/os/windows.yaml +++ b/data/os/windows.yaml @@ -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: ~ diff --git a/manifests/config.pp b/manifests/config.pp index 392b513..4df3a59 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -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"], diff --git a/manifests/init.pp b/manifests/init.pp index e2ba64c..fa7defb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 @@ -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, @@ -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, diff --git a/manifests/install.pp b/manifests/install.pp index 00af616..81546b8 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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 + } } } diff --git a/manifests/service.pp b/manifests/service.pp index 42dcb53..3d31f2f 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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 + } } } }