Skip to content

Commit

Permalink
Fixes #18757 - Move foreman-tasks service to Foreman
Browse files Browse the repository at this point in the history
As per #18618, the dynflow executor is moving over to Foreman, in order
to support ActiveJob. Tasks will provide an UI and persistence layer for
Dynflow, but Foreman should be able to run jobs without it too.

Part of this effort includes moving the Dynflow executor over to
Foreman, which at the moment is managed by the foreman-tasks service.
  • Loading branch information
dLobatog committed Mar 15, 2017
1 parent 5f9ae4c commit 55cdc15
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 14 deletions.
7 changes: 7 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:Boolean
class foreman (
$foreman_url = $::foreman::params::foreman_url,
$puppetrun = $::foreman::params::puppetrun,
Expand Down Expand Up @@ -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 ? {
Expand Down
8 changes: 8 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
14 changes: 6 additions & 8 deletions manifests/plugin/tasks.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:Boolean
#
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 {
unless $dynflow_in_core {
include ::foreman::tasks_service
}
foreman::plugin { 'tasks':
package => $package,
} ~>
service { 'foreman-tasks':
ensure => running,
enable => true,
name => $service,
}
}
2 changes: 0 additions & 2 deletions manifests/plugin/tasks/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
class foreman::plugin::tasks::params {
case $::osfamily {
'RedHat': {
$service = 'foreman-tasks'
case $::operatingsystem {
'fedora': {
$package = 'rubygem-foreman-tasks'
Expand All @@ -14,7 +13,6 @@
}
'Debian': {
$package = 'ruby-foreman-tasks'
$service = 'ruby-foreman-tasks'
}
/^(FreeBSD|DragonFly)$/: {
# do nothing to not break foreman-installer
Expand Down
4 changes: 4 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 28 additions & 0 deletions manifests/tasks_service.pp
Original file line number Diff line number Diff line change
@@ -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,
}
}
13 changes: 13 additions & 0 deletions spec/classes/foreman_tasks_service_spec.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions spec/classes/plugin/tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55cdc15

Please sign in to comment.