Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Redis URL #331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions manifests/config.pp
@@ -1,6 +1,13 @@
# Configures pulp3
# @api private
class pulpcore::config {
if $pulpcore::redis_url {
$redis_url = $pulpcore::redis_url
} else {
contain redis
$redis_url = "redis://localhost:${redis::port}/${pulpcore::redis_db}"
}

file { [$pulpcore::config_dir, $pulpcore::certs_dir]:
ensure => directory,
owner => 'root',
Expand Down
2 changes: 0 additions & 2 deletions manifests/database.pp
Expand Up @@ -39,6 +39,4 @@
refreshonly => false,
require => Pulpcore::Admin['migrate --noinput'],
}

contain redis
}
6 changes: 5 additions & 1 deletion manifests/init.pp
Expand Up @@ -109,8 +109,11 @@
# @param django_secret_key
# SECRET_KEY for Django
#
# @param redis_url
# Redis URL use. If not specified, a local server will be installed
#
# @param redis_db
# Redis DB number to use. By default, Redis supports a DB number of 0 through 15.
# The default DB to use when redis_url is not specified. By default, Redis supports a DB number of 0 through 15.
#
# @param servername
# Server name of the VirtualHost in the webserver
Expand Down Expand Up @@ -232,6 +235,7 @@
Optional[Stdlib::Absolutepath] $postgresql_db_ssl_key = undef,
Optional[Stdlib::Absolutepath] $postgresql_db_ssl_root_ca = undef,
String $django_secret_key = extlib::cache_data('pulpcore_cache_data', 'secret_key', extlib::random_password(50)),
Optional[Redis::RedisUrl] $redis_url = undef,
Integer[0] $redis_db = 8,
Stdlib::Fqdn $servername = $facts['networking']['fqdn'],
Array[Stdlib::Fqdn] $serveraliases = [],
Expand Down
12 changes: 12 additions & 0 deletions spec/classes/pulpcore_spec.rb
Expand Up @@ -6,9 +6,9 @@
let(:facts) { override_facts(os_facts, processors: {count: 1}, os: {selinux: {enabled: true}}) }

context 'default params' do
it { is_expected.to compile.with_all_deps }

Check failure on line 9 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

pulpcore on centos-8-x86_64 default params is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } error during compilation: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net

Check failure on line 9 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

pulpcore on centos-8-x86_64 default params is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } error during compilation: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net

it 'installs' do

Check failure on line 11 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

pulpcore on centos-8-x86_64 default params installs Failure/Error: is_expected.to contain_class('pulpcore::install') Puppet::ParseErrorWithIssue: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net

Check failure on line 11 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

pulpcore on centos-8-x86_64 default params installs Failure/Error: is_expected.to contain_class('pulpcore::install') Puppet::ParseErrorWithIssue: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net
is_expected.to contain_class('pulpcore::install')
is_expected.to contain_package('pulpcore')
is_expected.to contain_package('pulpcore-selinux')
Expand All @@ -16,7 +16,7 @@
is_expected.to contain_group('pulp')
end

it 'configures pulpcore' do

Check failure on line 19 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

pulpcore on centos-8-x86_64 default params configures pulpcore Failure/Error: is_expected.to contain_class('pulpcore::config') Puppet::ParseErrorWithIssue: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net

Check failure on line 19 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

pulpcore on centos-8-x86_64 default params configures pulpcore Failure/Error: is_expected.to contain_class('pulpcore::config') Puppet::ParseErrorWithIssue: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net
is_expected.to contain_class('pulpcore::config')
is_expected.to contain_concat('pulpcore settings').with_path('/etc/pulp/settings.py')
is_expected.to contain_concat__fragment('base')
Expand Down Expand Up @@ -59,14 +59,14 @@
is_expected.to contain_file('/var/lib/pulp/tmp')
end

it 'sets up static files' do

Check failure on line 62 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

pulpcore on centos-8-x86_64 default params sets up static files Failure/Error: is_expected.to contain_class('pulpcore::static') Puppet::ParseErrorWithIssue: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net

Check failure on line 62 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

pulpcore on centos-8-x86_64 default params sets up static files Failure/Error: is_expected.to contain_class('pulpcore::static') Puppet::ParseErrorWithIssue: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net
is_expected.to contain_class('pulpcore::static')
is_expected.to contain_file('/var/lib/pulp/assets')
is_expected.to contain_pulpcore__admin('collectstatic --noinput')
is_expected.to contain_exec('pulpcore-manager collectstatic --noinput')
end

it 'configures the database' do

Check failure on line 69 in spec/classes/pulpcore_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

pulpcore on centos-8-x86_64 default params configures the database Failure/Error: is_expected.to contain_class('pulpcore::database') Puppet::ParseErrorWithIssue: The parameter '$slowlog_log_slower_than' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: /home/runner/work/puppet-pulpcore/puppet-pulpcore/spec/fixtures/modules/redis/manifests/init.pp, line: 432, column: 15) on node fv-az774-694.j3qnnsaxsfoepktz21rketxmog.bx.internal.cloudapp.net
is_expected.to contain_class('pulpcore::database')
is_expected.to contain_class('postgresql::server')
is_expected.to contain_postgresql__server__db('pulpcore')
Expand Down Expand Up @@ -659,6 +659,18 @@
end
end
end

context 'with external redis' do
let(:params) do
{
redis_url: 'redis://redis.example.com:12345/7',
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_concat__fragment('base').with_content(include('REDIS_URL = "redis://redis.example.com:12345/7"')) }
it { is_expected.not_to contain_class('redis') }
end
end
end
end
2 changes: 1 addition & 1 deletion templates/settings.py.erb
Expand Up @@ -37,7 +37,7 @@ DATABASES = {
<% end -%>
},
}
REDIS_URL = "redis://localhost:<%= scope['redis::port'] %>/<%= scope['pulpcore::redis_db'] %>"
REDIS_URL = "<%= @redis_url %>"

<% if scope['pulpcore::worker_ttl'] -%>
WORKER_TTL = <%= scope['pulpcore::worker_ttl'] %>
Expand Down