Puppet Plan: cd4peadm::install::new::bootstrap

Defined in:
plans/install/new/bootstrap.pp

Summary

Interactive plan that prompts you for configuration information

Overview

Prompts you to answer questions to generate the configuration Hiera data file for use with cd4peadm::install

All sensitive data will be encrypted with hiera-eyaml

You must have an inventory.yaml file first.



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
# File 'plans/install/new/bootstrap.pp', line 11

plan cd4peadm::install::new::bootstrap(
) {
  $inventory_targets = cd4peadm::bolt_project_inventory_targets()

  if $inventory_targets.size == 0 {
    fail_plan('No targets found. Please create an inventory file. See <install docs>.')
  } elsif $inventory_targets.size == 1 {
    $use_inventory_target = Boolean(prompt("One target found in the inventory.  Use target ${inventory_targets[0].name} for AIO install?",
      'default' => 'yes')
    )
    if !$use_inventory_target {
      fail_plan('No other inventory targets found, please add more to your inventory file and run again')
    } else {
      $inventory_aio_target = $inventory_targets[0]
    }
  } else {
    $inventory_aio_target = prompt::menu('Found multiple targets, select target to install CD4PE on', $inventory_targets)
  }

  $target_hostname = $inventory_aio_target.uri ? {
    'localhost' => '',
    default     => $inventory_aio_target.uri
  }

  $hostname = cd4peadm::bolt_prompt_required_data('What is the resolvable hostname of the CD4PE web console?', false, $target_hostname)

  $admin_uname = prompt('Console admin username', 'default' => 'admin')
  $admin_pword = cd4peadm::bolt_prompt_required_data('Console admin password', true)

  $runtime = prompt::menu('Which container runtime should be installed on the target?', ['docker', 'podman'])
  $auto_config_db = Boolean(prompt('Would you like to auto-configure the database users and passwords?', 'default' => 'true'))
  if $auto_config_db {
    $admin_db_password = Sensitive(cd4peadm::secure_random(32))
    $cd4pe_db_password = Sensitive(cd4peadm::secure_random(32))
    $cd4pe_db_username = 'cd4pe'
    $query_db_password = Sensitive(cd4peadm::secure_random(32))
    $query_db_username = 'query'
  } else {
    $admin_db_password = cd4peadm::bolt_prompt_required_data('administrator database password', true)
    $cd4pe_db_username = prompt('cd4pe database username', 'default' => 'cd4pe')
    $cd4pe_db_password = cd4peadm::bolt_prompt_required_data('cd4pe database password', true)
    $query_db_username = prompt('query database username', 'default' => 'query')
    $query_db_password = cd4peadm::bolt_prompt_required_data('query database password', true)
  }

  run_plan('cd4peadm::generate_config', {
      admin_password       => $admin_pword,
      admin_username       => $admin_uname,
      admin_db_password    => $admin_db_password,
      cd4pe_db_password    => $cd4pe_db_password,
      cd4pe_db_username    => $cd4pe_db_username,
      query_db_password    => $query_db_password,
      query_db_username    => $query_db_username,
      inventory_aio_target => $inventory_aio_target.name,
      resolvable_hostname  => $hostname,
      runtime              => $runtime,
  })
}