Skip to content

Commit

Permalink
Fixes #36037 - Manage Redis service for Redis cache
Browse files Browse the repository at this point in the history
This automatically manages Redis when the cache store type is set to
Redis, but no URLs have been provided. It's assumed that when a URL is
provided that the service is managed in another way.

This ignores the edge case where the user wants to run it on localhost,
but with a different database than 0.
  • Loading branch information
ekohl committed Feb 2, 2023
1 parent f68bb4a commit 538f512
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 11 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
}
}

if $foreman::rails_cache_store['type'] == 'redis' {
if $foreman::rails_cache_store['urls'] {
$redis_cache_urls = prefix($foreman::rails_cache_store['urls'], 'redis://')
} else {
include redis
$redis_cache_urls = ["redis://localhost:${redis::port}/0"]
}
} else {
$redis_cache_urls = undef
}

# Used in the settings template
$websockets_ssl_cert = pick($foreman::websockets_ssl_cert, $foreman::server_ssl_cert)
$websockets_ssl_key = pick($foreman::websockets_ssl_key, $foreman::server_ssl_key)
Expand Down
8 changes: 2 additions & 6 deletions templates/settings.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@
:type: <%= scope["foreman::rails_cache_store"]["type"] %>
<% if scope["foreman::rails_cache_store"]["type"] == "redis" -%>
:urls:
<% if scope["foreman::rails_cache_store"].key?("urls") -%>
<% scope["foreman::rails_cache_store"]["urls"].each do |url| -%>
- redis://<%= url %>
<% end -%>
<% else -%>
- redis://localhost:8479/0
<% @redis_cache_urls.each do |url| -%>
- <%= url %>
<% end -%>
:options:
<% if scope["foreman::rails_cache_store"].key?("options") -%>
Expand Down

0 comments on commit 538f512

Please sign in to comment.