Puppet Plan: oci_config::start_instances

Defined in:
plans/start_instances.pp

Summary

This plan will start the specified OCI instances

Overview

See the file “LICENSE” for the full license governing this code.

--

–++–

Examples:

bolt plan run oci_config::start_instances oci_master=mypupptserver instances=mynode1,mynode2,mynode3

Parameters:

  • oci_master (TargetSpec) (defaults to: 'localhost')

    The Puppetserver that has the oci_config module installed and has one or more oci_tenant instances defined on it.

  • instances (TargetSpec)

    The OCI instanc names you want to start

  • max_retries (Integer) (defaults to: 2)


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
# File 'plans/start_instances.pp', line 19

plan oci_config::start_instances(
  TargetSpec $instances,
  Integer    $max_retries       = 2,
  TargetSpec $oci_master        = 'localhost',
) {
  if get_targets($oci_master).length > 1 {
    fail_plan("${oci_master} did not resolve to a single target")
  }

  $instance_nodes = get_targets($instances)

  $instance_nodes.each |$instance| {
    $hostname = $instance.host
    $node_facts = puppetdb_fact([$hostname])
    if $node_facts == {} {
      warning("Skipping node ${instance.host} not found in Puppetdb.")
    } elsif $node_facts.dig($hostname, 'oci_instance_id') == undef {
      warning("Skipping node ${instance.host} not an OCI node.")
    } else {
      $instance_id = $node_facts.dig($hostname, 'oci_instance_id')
      notice("Execute startup on OCI-level for ${hostname} with ocid ${instance_id}...")
      run_task('oci_config::instance_action', $oci_master,
        instance_id => $instance_id,
        max_retries => $max_retries,
        action => 'START' )
    }
  }
}