Puppet Plan: cd4peadm::install::from_4x::generate_config
- Defined in:
- plans/install/from_4x/generate_config.pp
Overview
Extracts config settings from the 4.x install and creates a Hiera config file for the new 5.x install with them.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'plans/install/from_4x/generate_config.pp', line 4
plan cd4peadm::install::from_4x::generate_config(
Target $cd4pe_4_target,
Target $cd4pe_5_target,
String $hostname,
String $runtime,
Sensitive[String] $admin_db_password,
Sensitive[String] $console_root_password,
) {
$root_email = cd4peadm::kubectl(
$cd4pe_4_target,
'get secret cd4pe-root -o jsonpath=\'{.data.email}\' | base64 -d'
)[0].value['stdout']
$pfi_config = cd4peadm::kubectl(
$cd4pe_4_target,
'get secret cd4pe-config -o jsonpath=\'{.data.pfi-config\\.json}\' | base64 -d'
)[0].value['stdout'].parsejson
$db_secret_key = $pfi_config['secretKey']
$cd4pe_db_creds = cd4peadm::kubectl(
$cd4pe_4_target,
'get secret cd4pe-postgres -o jsonpath=\'{.data}\''
)[0].value['stdout'].parsejson
$cd4pe_db_user = base64('decode', $cd4pe_db_creds['user'])
$cd4pe_db_password = base64('decode', $cd4pe_db_creds['password'])
$query_db_creds = cd4peadm::kubectl(
$cd4pe_4_target,
'get secret query-postgres -o jsonpath=\'{.data}\''
)[0].value['stdout'].parsejson
$query_db_user = base64('decode', $query_db_creds['POSTGRES_USER'])
$query_db_password = base64('decode', $query_db_creds['POSTGRES_PASSWORD'])
$pod_env_vars = cd4peadm::kubectl(
$cd4pe_4_target,
'get pod -l app.kubernetes.io/name=cd4pe -o jsonpath=\'{.items[0].spec.containers[0].env}\''
)[0].value['stdout'].parsejson
$env_hash = cd4peadm::migrate::env_to_hash($pod_env_vars)
$optional_settings = {
# PipelinesInfra advanced settings
'job_http_read_timeout_mins' => cd4peadm::maybe_to_int($env_hash['CD4PE_JOB_HTTP_READ_TIMEOUT_MINUTES']),
'job_global_timeout_mins' => cd4peadm::maybe_to_int($env_hash['CD4PE_JOB_GLOBAL_TIMEOUT_MINUTES']),
'ldap_group_search_size_limit' => cd4peadm::maybe_to_int($env_hash['CD4PE_LDAP_GROUP_SEARCH_SIZE_LIMIT']),
'repo_cache_retrieval_timeout_mins' => cd4peadm::maybe_to_int($env_hash['CD4PE_REPO_CACHE_RETRIEVAL_TIMEOUT_MINUTES']),
'bolt_pcp_read_timeout_secs' => cd4peadm::maybe_to_int($env_hash['CD4PE_BOLT_PCP_READ_TIMEOUT_SEC']),
'http_connection_timeout_secs' => cd4peadm::maybe_to_int($env_hash['CD4PE_HTTP_CONNECTION_TIMEOUT_SEC']),
'http_read_timeout_secs' => cd4peadm::maybe_to_int($env_hash['CD4PE_HTTP_READ_TIMEOUT_SEC']),
'http_write_timeout_secs' => cd4peadm::maybe_to_int($env_hash['CD4PE_HTTP_WRITE_TIMEOUT_SEC']),
'http_request_timeout_secs' => cd4peadm::maybe_to_int($env_hash['CD4PE_HTTP_REQUEST_TIMEOUT_SEC']),
'puppetdb_connection_timeout_secs' => cd4peadm::maybe_to_int($env_hash['PUPPETDB_CONNECTION_TIMEOUT_SEC']),
'max_login_attempts' => cd4peadm::maybe_to_int($env_hash['CD4PE_MAX_LOGIN_ATTEMPTS']),
'failed_login_attempt_period_mins' => cd4peadm::maybe_to_int($env_hash['CD4PE_FAILED_LOGIN_ATTEMPT_PERIOD_IN_MINS']),
'lockout_period_mins' => cd4peadm::maybe_to_int($env_hash['CD4PE_LOCKOUT_PERIOD_IN_MINS']),
'repo_caching' => cd4peadm::maybe_to_bool($env_hash['CD4PE_REPO_CACHING']),
'include_git_history_for_jobs' => cd4peadm::maybe_to_bool($env_hash['CD4PE_INCLUDE_GIT_HISTORY_FOR_CD4PE_JOBS']),
# Query Service advanced settings
'enable_report_templates' => cd4peadm::maybe_to_bool($env_hash['ENABLE_REPORT_TEMPLATES']),
'query_complexity_limit' => cd4peadm::maybe_to_int($env_hash['QUERY_COMPLEXITY_LIMIT']),
}
run_plan('cd4peadm::generate_config', {
admin_password => $console_root_password,
admin_username => $root_email,
secret_key => Sensitive($db_secret_key),
admin_db_password => $admin_db_password,
cd4pe_db_password => Sensitive($cd4pe_db_password),
cd4pe_db_username => $cd4pe_db_user,
query_db_password => Sensitive($query_db_password),
query_db_username => $query_db_user,
inventory_aio_target => $cd4pe_5_target.name,
resolvable_hostname => $hostname,
runtime => $runtime,
optional_settings => $optional_settings,
})
}
|