Puppet Plan: cd4peadm::install::bootstrap_and_get_v4_target
- Defined in:
- plans/install/bootstrap_and_get_v4_target.pp
Overview
Ensures hiera configuration is present. Either it is pre-existing, in which case the user will have passed in the use_existing_configuration parameter, or we will prompt for the information needed by calling the bootstrap plan.
If the user is using the existing configuration, we just prompt for the v4 target and return. If the user is not using the existing configuration, this plan just calls the bootstrap plan and returns the v4 target.
If the v4_node is provided, but not the use_existing_configuration, we will ignore the v4_node and prompt for everything.
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 |
# File 'plans/install/bootstrap_and_get_v4_target.pp', line 22
plan cd4peadm::install::bootstrap_and_get_v4_target(
Optional[Boolean] $use_existing_configuration = false,
Optional[Target] $cd4pe_v4_node = undef,
) {
$config_path = "${cd4peadm::bolt_project_dir()}/data/common.yaml"
$use_existing = $use_existing_configuration ? {
true => file::exists($config_path) ? {
true => true,
default => fail_plan("Found `use_existing_configuration` set, but no existing configuration found at ${config_path}."),
},
default => file::exists($config_path) ? {
true => Boolean(prompt("Existing config found at ${config_path}. Would you like to use it?", 'default' => 'yes')),
default => false,
}
}
if $use_existing {
out::message('Using existing config.')
run_plan('cd4peadm::install::create_hiera_config')
$inventory_targets = cd4peadm::bolt_project_inventory_targets()
if $inventory_targets.size == 0 {
fail_plan(@(MESSAGE)
No targets found. Please add a target to your inventory file with access to you CD4PE 4 host.
See https://www.puppet.com/docs/continuous-delivery/5.x/migrate_5_x.
| MESSAGE
)
}
$cd4pe_4_target = $cd4pe_v4_node ? {
undef => prompt::menu('Select target with access to CD4PE 4 host', $inventory_targets),
default => $cd4pe_v4_node
}
} else { # overwrite existing config
$cd4pe_4_target = run_plan('cd4peadm::install::from_4x::bootstrap')
}
out::message('migration_version_check: Checking for minimum CD4PE version needed for migration')
$migration_version_check_result = run_plan('cd4peadm::preflight::migration_version_check', {
cd4pe_4_target => $cd4pe_4_target,
})
out::message(cd4peadm::checks::format_results($migration_version_check_result))
if(length($migration_version_check_result[failed]) > 0) {
fail_plan('One or more preflight checks did not pass', 'cd4pe/error')
}
return($cd4pe_4_target)
}
|