Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}

if $foreman::dynflow_manage_services {
$dynflow_service_filename = '/usr/lib/systemd/system/[email protected]'
if $foreman::dynflow_redis_url != undef {
$dynflow_redis_url = $foreman::dynflow_redis_url
} else {
Expand All @@ -15,6 +16,16 @@
Class['redis'] -> Service <| tag == 'foreman::dynflow::worker' |>
}

file { $dynflow_service_filename:
ensure => file,
mode => '0644',
owner => root,
group => root,
content => epp("${module_name}/[email protected]", {
redis_host => $foreman::dynflow_redis_url,
}),
}

file { '/etc/foreman/dynflow':
ensure => directory,
}
Expand Down
18 changes: 18 additions & 0 deletions spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,24 @@
end
end

describe 'with custom redis for dynflow' do
context 'with redis_url for dynflow' do
let(:params) do
super().merge(
dynflow_redis_url: 'redis://127.0.0.1:6379/7',
rails_cache_store: {type: 'file'}
)
end

it { should_not contain_class('redis') }
it { should_not contain_class('redis::instance') }
it do
is_expected.to contain_file('/usr/lib/systemd/system/[email protected]')
.with_content(/^.*redis:\/\/127\.0\.0\.1:6379\/7.*$/)
end
end
end

describe 'with non-Puppet SSL certificates' do
let(:params) do
super().merge(
Expand Down
41 changes: 41 additions & 0 deletions templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<%- |
Optional[Redis::RedisUrl] $redis_host,
| -%>

# This file is managed by Puppet

[Unit]
Description=Foreman jobs daemon - %i on sidekiq
Documentation=https://theforeman.org
After=network.target remote-fs.target nss-lookup.target
PartOf=foreman.service

[Service]
Type=notify
User=foreman
TimeoutSec=300
PrivateTmp=true
Environment=RAILS_ENV=production
Environment=DYNFLOW_SIDEKIQ_SCRIPT=/usr/share/foreman/extras/dynflow-sidekiq.rb
<% if $redis_host { -%>
Environment=DYNFLOW_REDIS_URL=<%= $redis_host %>
<% } -%>
<% else { -%>
Environment=DYNFLOW_REDIS_URL=redis://localhost:6379/6
<% } -%>
Environment=REDIS_PROVIDER=DYNFLOW_REDIS_URL
# Greatly reduce Ruby memory fragmentation and heap usage
# https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
Environment=MALLOC_ARENA_MAX=2
WorkingDirectory=/usr/share/foreman
ExecStart=/usr/libexec/foreman/sidekiq-selinux -e ${RAILS_ENV} -r ${DYNFLOW_SIDEKIQ_SCRIPT} -C /etc/foreman/dynflow/%i.yml
ExecReload=/usr/bin/kill -TSTP $MAINPID

SyslogIdentifier=dynflow-sidekiq@%i

# if we crash, restart
RestartSec=1
Restart=on-failure

[Install]
WantedBy=multi-user.target