diff --git a/manifests/init.pp b/manifests/init.pp index eb578d20d..131e1bb52 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -285,6 +285,11 @@ # $email_conf:: Email configuration file under /etc/foreman # type:String # +# $tasks_service:: Name of the service for running the background Dynflow executor +# type:String +# +# $dynflow_in_core:: Whether the Dynflow executor service is provided by Foreman or tasks +# type:String class foreman ( $foreman_url = $::foreman::params::foreman_url, $puppetrun = $::foreman::params::puppetrun, @@ -376,6 +381,8 @@ $email_smtp_authentication = $::foreman::params::email_smtp_authentication, $email_smtp_user_name = $::foreman::params::email_smtp_user_name, $email_smtp_password = $::foreman::params::email_smtp_password, + $tasks_service = $::foreman::params::tasks_service, + $dynflow_in_core = $::foreman::params::dynflow_in_core, ) inherits foreman::params { if $db_adapter == 'UNSET' { $db_adapter_real = $::foreman::db_type ? { diff --git a/manifests/params.pp b/manifests/params.pp index 2b1ca61ef..fe65852d5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -99,6 +99,7 @@ $init_config_tmpl = 'foreman.sysconfig' $puppet_etcdir = '/etc/puppet' $puppet_home = '/var/lib/puppet' + $tasks_service = 'foreman-tasks' case $::operatingsystem { 'fedora': { @@ -131,6 +132,7 @@ $plugin_prefix = 'ruby-foreman-' $init_config = '/etc/default/foreman' $init_config_tmpl = 'foreman.default' + $tasks_service = 'ruby-foreman-tasks' } 'Linux': { case $::operatingsystem { @@ -253,4 +255,10 @@ $server_port = 80 $server_ssl_port = 443 + # Define job processing service properties + $tasks_service_ensure = 'running' + $tasks_service_enable = true + + # Defines whether Foreman or the tasks plugin provides the Dynflow executor + $dynflow_in_core = true } diff --git a/manifests/plugin/tasks.pp b/manifests/plugin/tasks.pp index c6cf68b27..9b7473dfd 100644 --- a/manifests/plugin/tasks.pp +++ b/manifests/plugin/tasks.pp @@ -7,19 +7,17 @@ # $package:: Package name to install, use ruby193-rubygem-foreman-tasks on Foreman 1.8/1.9 on EL # type:String # -# $service:: Service name -# type:String +# $dynflow_in_core:: Whether Foreman ships the Dynflow executor service (true on 1.15+) +# type:String # class foreman::plugin::tasks( $package = $foreman::plugin::tasks::params::package, - $service = $foreman::plugin::tasks::params::service, + $dynflow_in_core = $::foreman::dynflow_in_core, ) inherits foreman::plugin::tasks::params { + if $dynflow_in_core == false { + include ::foreman::tasks_service + } foreman::plugin { 'tasks': package => $package, - } ~> - service { 'foreman-tasks': - ensure => running, - enable => true, - name => $service, } } diff --git a/manifests/plugin/tasks/params.pp b/manifests/plugin/tasks/params.pp index b8e025bc8..03b63e44a 100644 --- a/manifests/plugin/tasks/params.pp +++ b/manifests/plugin/tasks/params.pp @@ -2,7 +2,6 @@ class foreman::plugin::tasks::params { case $::osfamily { 'RedHat': { - $service = 'foreman-tasks' case $::operatingsystem { 'fedora': { $package = 'rubygem-foreman-tasks' @@ -14,7 +13,6 @@ } 'Debian': { $package = 'ruby-foreman-tasks' - $service = 'ruby-foreman-tasks' } /^(FreeBSD|DragonFly)$/: { # do nothing to not break foreman-installer diff --git a/manifests/service.pp b/manifests/service.pp index e7c7d99ee..96411df97 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,7 +3,11 @@ $passenger = $::foreman::passenger, $app_root = $::foreman::app_root, $ssl = $::foreman::ssl, + $dynflow_in_core = $::foreman::dynflow_in_core, ) { + if $dynflow_in_core { + include ::foreman::tasks_service + } anchor { ['foreman::service_begin', 'foreman::service_end']: } if $passenger { diff --git a/manifests/tasks_service.pp b/manifests/tasks_service.pp new file mode 100644 index 000000000..6fab3d61e --- /dev/null +++ b/manifests/tasks_service.pp @@ -0,0 +1,28 @@ +# = foreman-tasks service +# +# Service for the foreman-tasks service, which starts a Dynflow executor +# for background job processing in Foreman. Not to be confused with the +# foreman-tasks plugin. +# +# === Parameters: +# +# $service:: Service name +# type:String +# +# $ensure:: State the service should be in +# type:Enum['absent', 'present'] +# +# $enable:: Whether to enable the service or not +# type:String + +class foreman::tasks_service( + $service = $::foreman::params::tasks_service, + $ensure = $::foreman::params::tasks_service_ensure, + $enable = $::foreman::params::tasks_service_enable, +) inherits foreman::params { + service { 'foreman-tasks': + ensure => $ensure, + enable => $enable, + name => $service, + } +} diff --git a/spec/classes/foreman_tasks_service_spec.rb b/spec/classes/foreman_tasks_service_spec.rb new file mode 100644 index 000000000..db45e363a --- /dev/null +++ b/spec/classes/foreman_tasks_service_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe 'foreman::tasks_service' do + let :facts do + on_supported_os['redhat-7-x86_64'] + end + + it { should contain_service('foreman-tasks').with({ + 'ensure' => 'running', + 'enable' => true, + 'name' => 'foreman-tasks' + })} +end diff --git a/spec/classes/plugin/tasks_spec.rb b/spec/classes/plugin/tasks_spec.rb index 27b5139d1..daa501e1a 100644 --- a/spec/classes/plugin/tasks_spec.rb +++ b/spec/classes/plugin/tasks_spec.rb @@ -17,20 +17,16 @@ else 'tfm-rubygem-foreman-tasks' end - service_name = 'foreman-tasks' when 'Debian' package_name = 'ruby-foreman-tasks' - service_name = 'ruby-foreman-tasks' else package_name = 'foreman-tasks' - service_name = 'foreman-tasks' end it { should compile.with_all_deps } it 'should call the plugin' do should contain_foreman__plugin('tasks').with_package(package_name) - should contain_service('foreman-tasks').with('ensure' => 'running', 'enable' => 'true', 'name' => service_name) end end end