Overview

Ansible and Oracle allow you to automate a lot of things around the OCI. In this module we will address the automation of:

Compute Node Creation

MySQL Creation

MySQL Replication Setup

In later modules, we will make it even better with the introduction of roles. So let's get going. P.S. A disclaimer is in order here….I will not share my compartment or SSH keys…..obviously :D

Compute Node

Ansible has variable of modules for the compute node or for anything in general, but the following playbook automate the creation of a compute node.

Of course you need to create a VCN prior that with the correct name:

Create a compute node

Actually that command, created the server on which that page is currently running :D

Playbook

The playbook you can see below:

setup_computenode.yml

So the playbook, won't create a compute node which already exist and it will also verify that the server has been created :)

MySQL Setup

Now, since OCI stands for Oracle Cloud Interface, well…they have Oracle Linux and AS SUCH, by default it is MySQL 8, so…my first task is to DELETE the MySQL 8 :D in my playbook. Then I install the new packages and so on so far…. :)

MySQL Deployment

For the people who are wondering what the: “oci_inventory.py” is. It is a file by Oracle, which allows you to create dynamic inventory based on your OCI, so I don't have to keep a track of if a server still exist or I killed it….brutally I might add.

Playbook

Again, the playbook you can see below:

setup_mysql.yml

Now, of course, I will change the configuration with a template and so on, but that is for a later module.