Getting to know the Oracle cloud with Puppet, part 2

Getting to know the Oracle cloud with Puppet, part 2 The Oracle Cloud or OCI is an extensive Cloud offering by Oracle. The possibilities are enormous. In part 1 we started exploring The Oracle cloud with Puppet. The first steps where installing the modules and making sure th authentication is set up correctly. Now we are going to continue on our journey and are inspecting and creating a network setup and an initial VM.

Looking at our compartments

The last thing we discussed in the previous blog posts is looking at the compartments. As a refresher, here is the command and the output.

$ puppet resource oci_identity_compartment
bash-4.2# puppet resource oci_identity_compartment
*** ENTERPRISE MODULES Universal License INTERNAL USE ONLY ***
oci_identity_compartment { 'your_tenant (root)/ManagedCompartmentForPaaS':
  ensure          => 'present',
  compartment     => '/',
  compartment_id  => 'ocid1.tenancy.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  description     => 'idcs-f7246e2bbacf4a11a7e231507e34fdec|22626923|user@domain.com-Enterprise Modules B.V.-838062',
  id              => 'ocid1.compartment.oc1..aaaaaaaai2wkrvdvyxfuekjbt3jnv7b4hrlkvwnklu6uryy2daqsq425tzaa',
  lifecycle_state => 'ACTIVE',
  provider        => 'sdk',
  time_created    => '2019-10-24T08:42:26+00:00',
}
oci_identity_compartment { 'your_tenant (root)/test_compartment_1':
  ensure          => 'present',
  compartment     => '/',
  compartment_id  => 'ocid1.tenancy.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  description     => 'changed',
  id              => 'ocid1.compartment.oc1..aaaaaaaatfskqfckrl4sucabclbsss47uyttlmwwur6lsm7crl3lrz7glfta',
  lifecycle_state => 'ACTIVE',
  provider        => 'sdk',
  time_created    => '2020-01-23T15:42:35+00:00',
}

When we look at the information returned, we see a lot of properties. Let’s discuss some of these properties:

id

Every object in the Oracle cloud has an id. Sometims refered to as OCID (Oracle Cloud ID). This id uniquely identifies an object in the Oracle Cloud. In many Infrastructure As Code tools, you have to know and use these ids. It is the only way. In Puppet you can refer to an object either by id or by it’s name. In general it produces better readable Puppet code when you use the name.

Lifecycle state

Almost all objects in the Oracle cloud have a state. When you are creating a VM instance for instance, the state changes from PROVISIONING to ACTIVE. When you delete a VM instance, it changes through TERMINATING to TERMINATED. In Puppet, you will ONLY see the Oracle Cloud objects that are in a state ACTIVE or a similar state. The oci_config module does this to make sure you are always manipulating the current state. The $ puppet resource oci_.... command reports the state, but it is a read-only parameter. You cannot directly manage this state with Puppet. When making your OCI Puppet code, you will never use this property.

time_created

The setup described in this blog post is targeted at learning OCI and learning about the oci_config module. We can also fully automate all of this, but that is the contents of an other blog post.