Skip to content

Commit 3c5bc3f

Browse files
ianballouekohl
authored andcommitted
Refs #37325 - optional container gateway PG management
1 parent 7d79605 commit 3c5bc3f

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

manifests/plugin/container_gateway.pp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#
77
# $database_backend:: 'sqlite' or 'postgres'
88
#
9+
# $manage_postgresql:: If the PostgreSQL database should be managed
10+
#
911
# $postgresql_host:: Host of the postgres database.
1012
#
1113
# $postgresql_port:: Port of the postgres database.
@@ -37,6 +39,7 @@
3739
String $database_backend = 'postgres',
3840
Stdlib::Absolutepath $sqlite_db_path = '/var/lib/foreman-proxy/smart_proxy_container_gateway.db',
3941
Optional[Integer] $sqlite_timeout = undef,
42+
Boolean $manage_postgresql = true,
4043
Stdlib::Host $postgresql_host = 'localhost',
4144
Stdlib::Port $postgresql_port = 5432,
4245
String $postgresql_database = 'container_gateway',
@@ -49,15 +52,18 @@
4952
feature => 'Container_Gateway',
5053
listen_on => $listen_on,
5154
}
52-
include postgresql::server
53-
postgresql::server::db { $foreman_proxy::plugin::container_gateway::postgresql_database:
54-
user => $foreman_proxy::plugin::container_gateway::postgresql_user,
55-
password => postgresql::postgresql_password(
56-
$foreman_proxy::plugin::container_gateway::postgresql_user,
57-
$foreman_proxy::plugin::container_gateway::postgresql_password
58-
),
59-
encoding => 'utf8',
60-
locale => 'en_US.utf8',
61-
require => Package['glibc-langpack-en'],
55+
56+
if $foreman_proxy::plugin::container_gateway::manage_postgresql {
57+
include postgresql::server
58+
postgresql::server::db { $foreman_proxy::plugin::container_gateway::postgresql_database:
59+
user => $foreman_proxy::plugin::container_gateway::postgresql_user,
60+
password => postgresql::postgresql_password(
61+
$foreman_proxy::plugin::container_gateway::postgresql_user,
62+
$foreman_proxy::plugin::container_gateway::postgresql_password
63+
),
64+
encoding => 'utf8',
65+
locale => 'en_US.utf8',
66+
require => Package['glibc-langpack-en'],
67+
}
6268
}
6369
}

spec/classes/foreman_proxy__plugin__container_gateway_spec.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
':enabled: https',
1616
":pulp_endpoint: https://#{facts[:fqdn]}",
1717
':database_backend: postgresql',
18-
':postgresql_host: localhost',
19-
':postgresql_port: 5432',
20-
':postgresql_database: container_gateway',
21-
':postgresql_user: foreman-proxy',
22-
':postgresql_password: changeme',
23-
':sqlite_db_path: /var/lib/foreman-proxy/smart_proxy_container_gateway.db'
18+
':sqlite_db_path: /var/lib/foreman-proxy/smart_proxy_container_gateway.db',
19+
':postgresql_connection_string: postgres://foreman-proxy:changeme@localhost:5432/container_gateway'
2420
])
2521
end
2622
end
@@ -46,11 +42,7 @@
4642
':database_backend: postgresql',
4743
':sqlite_db_path: /dev/null.db',
4844
':sqlite_timeout: 12345',
49-
':postgresql_host: test.example.com',
50-
':postgresql_port: 5432',
51-
':postgresql_database: container_gateway',
52-
':postgresql_user: foreman-proxy',
53-
':postgresql_password: changeme'
45+
':postgresql_connection_string: postgres://foreman-proxy:[email protected]:5432/container_gateway'
5446
])
5547
end
5648
end

templates/plugin/container_gateway.yml.erb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,4 @@
1313
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_host")}:" \
1414
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_port")}/" \
1515
"#{scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_database")}"
16-
%>
17-
:postgresql_host: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_host") %>
18-
:postgresql_port: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_port") %>
19-
:postgresql_user: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_user") %>
20-
:postgresql_password: <%= scope.lookupvar("foreman_proxy::plugin::container_gateway::postgresql_password") %>
16+
%>

0 commit comments

Comments
 (0)