Skip to content

Commit

Permalink
Merge pull request #187 from treydock/configs
Browse files Browse the repository at this point in the history
Split config.cli templates into smaller files, use epp templates
  • Loading branch information
treydock authored Mar 7, 2021
2 parents ff98a39 + 9a58002 commit 85cf51e
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 229 deletions.
123 changes: 112 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

$_add_user_keycloak_cmd = "${keycloak::install_base}/bin/add-user-keycloak.sh"
$_add_user_keycloak_state = "${keycloak::install_base}/.create-keycloak-admin-${keycloak::datasource_driver}"
$_config_cli_content = template('keycloak/config.cli.erb')

if $::keycloak::operating_mode != 'domain' {
$_add_user_keycloak_args = "--user ${keycloak::admin_user} --password ${keycloak::admin_user_password} --realm master"
Expand Down Expand Up @@ -63,29 +62,132 @@
user => $keycloak::user,
}

if $keycloak::operating_mode == 'domain' {
$config_cli_prefix = '/profile=auth-server-clustered'
} else {
$config_cli_prefix = ''
}

concat { "${keycloak::install_base}/config.cli":
owner => $keycloak::user,
group => $keycloak::group,
mode => '0600',
notify => Exec['jboss-cli.sh --file=config.cli'],
show_diff => false,
owner => $keycloak::user,
group => $keycloak::group,
mode => '0600',
notify => Exec['jboss-cli.sh --file=config.cli'],
show_diff => false,
ensure_newline => true,
}

concat::fragment { 'config.cli-keycloak':
concat::fragment { 'keycloak-config.cli-header':
target => "${keycloak::install_base}/config.cli",
content => $_config_cli_content,
content => epp('keycloak/config.cli/00-header.epp', {'operating_mode' => $keycloak::operating_mode}),
order => '00',
}

if $keycloak::proxy_https {
concat::fragment { 'keycloak-config.cli-https-proxy':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/01-https-proxy.epp', {'prefix' => $config_cli_prefix}),
order => '01',
}
}

concat::fragment { 'keycloak-config.cli-datasource':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/02-datasource.epp', {
'datasource_driver' => $keycloak::datasource_driver,
'datasource_connection_url' => $keycloak::datasource_connection_url,
'datasource_username' => $keycloak::datasource_username,
'datasource_password' => $keycloak::datasource_password,
'mysql_datasource_class' => $keycloak::mysql_datasource_class,
'prefix' => $config_cli_prefix,
}),
order => '02',
}

concat::fragment { 'keycloak-config.cli-truststore':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/03-truststore.epp', {
'truststore' => $keycloak::truststore,
'operating_mode' => $keycloak::operating_mode,
'install_base' => $keycloak::install_base,
'truststore_password' => $keycloak::truststore_password,
'truststore_hostname_verification_policy' => $keycloak::truststore_hostname_verification_policy,
'prefix' => $config_cli_prefix,
}),
order => '03',
}

concat::fragment { 'keycloak-config.cli-theming':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/04-theming.epp', {
'theme_static_max_age' => $keycloak::theme_static_max_age,
'theme_cache_themes' => $keycloak::theme_cache_themes,
'theme_cache_templates' => $keycloak::theme_cache_templates,
'prefix' => $config_cli_prefix,
}),
order => '04',
}

# deployment scanner is not compatible with domain mode
if $keycloak::operating_mode != 'domain' {
concat::fragment { 'keycloak-config.cli-deployment-scanner':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/05-deployment-scanner.epp', {
'auto_deploy_exploded' => $keycloak::auto_deploy_exploded,
'auto_deploy_zipped' => $keycloak::auto_deploy_zipped,
'prefix' => $config_cli_prefix,
}),
order => '05',
}
}

concat::fragment { 'keycloak-config.cli-user-cache':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/06-user-cache.epp', {
'user_cache' => $keycloak::user_cache,
'prefix' => $config_cli_prefix,
}),
order => '06',
}

concat::fragment { 'keycloak-config.cli-cluster':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/10-cluster.epp', {
'operating_mode' => $keycloak::operating_mode,
'enable_jdbc_ping' => $keycloak::enable_jdbc_ping,
'datasource_driver' => $keycloak::datasource_driver,
'jboss_bind_private_address' => $keycloak::jboss_bind_private_address,
'jboss_bind_public_address' => $keycloak::jboss_bind_public_address,
'prefix' => $config_cli_prefix,
}),
order => '10',
}

if $keycloak::operating_mode == 'domain' {
concat::fragment { 'keycloak-config.cli-domain':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/11-domain.epp', {
'prefix' => $config_cli_prefix,
}),
order => '11',
}
}

if $keycloak::custom_config_content or $keycloak::custom_config_source {
concat::fragment { 'config.cli-custom':
concat::fragment { 'keycloak-config.cli-custom':
target => "${keycloak::install_base}/config.cli",
content => $keycloak::custom_config_content,
source => $keycloak::custom_config_source,
order => '01',
order => '50',
}
}

concat::fragment { 'keycloak-config.cli-footer':
target => "${keycloak::install_base}/config.cli",
content => epp('keycloak/config.cli/99-footer.epp', {'operating_mode' => $keycloak::operating_mode}),
order => '99',
}

exec { 'jboss-cli.sh --file=config.cli':
command => "${keycloak::install_base}/bin/jboss-cli.sh --file=config.cli",
cwd => $keycloak::install_base,
Expand Down Expand Up @@ -150,7 +252,6 @@
}

if $keycloak::role == 'master' {

# Remove load balancer group
# Rename the server
# Set port offset to zero to run server on port 8080
Expand Down
8 changes: 0 additions & 8 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,6 @@
)
end

it do
is_expected.to contain_concat__fragment('config.cli-keycloak').with(
target: "/opt/keycloak-#{version}/config.cli",
content: %r{.*},
order: '00',
)
end

it do
is_expected.to contain_file_line('keycloak-JAVA_OPTS').with(
ensure: 'absent',
Expand Down
Loading

0 comments on commit 85cf51e

Please sign in to comment.