Skip to content

Commit 9534286

Browse files
committed
Configurable Redis URL
This allows users to run with a remote Redis server.
1 parent cc20358 commit 9534286

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

manifests/config.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Configures pulp3
22
# @api private
33
class pulpcore::config {
4+
if $pulpcore::redis_url {
5+
$redis_url = $pulpcore::redis_url
6+
} else {
7+
contain redis
8+
$redis_url = "redis://localhost:${redis::port}/${pulpcore::redis_db}"
9+
}
10+
411
file { [$pulpcore::config_dir, $pulpcore::certs_dir]:
512
ensure => directory,
613
owner => 'root',

manifests/database.pp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,4 @@
3939
refreshonly => false,
4040
require => Pulpcore::Admin['migrate --noinput'],
4141
}
42-
43-
contain redis
4442
}

manifests/init.pp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@
109109
# @param django_secret_key
110110
# SECRET_KEY for Django
111111
#
112+
# @param redis_url
113+
# Redis URL use. If not specified, a local server will be installed
114+
#
112115
# @param redis_db
113-
# Redis DB number to use. By default, Redis supports a DB number of 0 through 15.
116+
# The default DB to use when redis_url is not specified. By default, Redis supports a DB number of 0 through 15.
114117
#
115118
# @param servername
116119
# Server name of the VirtualHost in the webserver
@@ -232,6 +235,7 @@
232235
Optional[Stdlib::Absolutepath] $postgresql_db_ssl_key = undef,
233236
Optional[Stdlib::Absolutepath] $postgresql_db_ssl_root_ca = undef,
234237
String $django_secret_key = extlib::cache_data('pulpcore_cache_data', 'secret_key', extlib::random_password(50)),
238+
Optional[Redis::RedisUrl] $redis_url = undef,
235239
Integer[0] $redis_db = 8,
236240
Stdlib::Fqdn $servername = $facts['networking']['fqdn'],
237241
Array[Stdlib::Fqdn] $serveraliases = [],

spec/classes/pulpcore_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,18 @@
659659
end
660660
end
661661
end
662+
663+
context 'with external redis' do
664+
let(:params) do
665+
{
666+
redis_url: 'redis://redis.example.com:12345/7',
667+
}
668+
end
669+
670+
it { is_expected.to compile.with_all_deps }
671+
it { is_expected.to contain_concat__fragment('base').with_content(include('REDIS_URL = "redis://redis.example.com:12345/7"')) }
672+
it { is_expected.not_to contain_class('redis') }
673+
end
662674
end
663675
end
664676
end

templates/settings.py.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ DATABASES = {
3737
<% end -%>
3838
},
3939
}
40-
REDIS_URL = "redis://localhost:<%= scope['redis::port'] %>/<%= scope['pulpcore::redis_db'] %>"
40+
REDIS_URL = "<%= @redis_url %>"
4141

4242
<% if scope['pulpcore::worker_ttl'] -%>
4343
WORKER_TTL = <%= scope['pulpcore::worker_ttl'] %>

0 commit comments

Comments
 (0)