Have you ever wondered if you can use Ansible with Oracle Autonomous Database on Dedicated Exadata Infrastructure? The answer is absolutely! Since I recently helped update the Ansible Autonomous Database samples to include Dedicated, and the GitHub updates have merged, I thought a blog post about what they do and how to use them was in order.
The sample scripts assume that an Exadata Infrastructure has been created and an Autonomous Exadata VM Cluster is running on top of it. These resources are the minimum requirements for running the Ansible sample.
There are two Ansible files needed (located here):
sample.yaml is the main script and will (1) create a new Autonomous Container Database (ACD); (2) create a new Autonomous Database (ADB) on top of the newly created ACD; (3) list ADBs in a compartment filtered by display name; (4) get facts of the ADB that was created earlier; (5) stop/start the ADB; and (6) kick off the cleanup script.
teardown.yaml is the cleanup script and cannot be run by itself. When run from the main script, the created ADB and ACD will be deleted, in that order. This script can take extra time to run as it has a looping wait coded in it, which ensures that the ACD is in the correct state before attempting to delete it. After an ACD is created, a backup is taken – this step must be completed before a delete operation is allowed. The teardown script handles everything automatically. If you want to keep the ACD and ADB for testing, the teardown.yaml file can be commented out of the sample.yaml.
To use the sample, we need somewhere to install the OCI Ansible Collection and its dependencies, OCI SDK for Python and Ansible. An OCI Oracle Linux 8 compute instance is perfect for this.
Here is the image and shape profile I used for my virtual machine (VM):
In a few minutes or less, the VM will be up and running. After logging in as OPC, we need to get the necessary software downloaded and setup:
sudo yum install -y oci-ansible-collection --enablerepo ol8_developer --enablerepo ol8_developer_EPEL
After installing the RPM and the dependencies, you must configure the SDK and CLI configuration file as explained in
Configuring Authentication.
The default configuration file name and location is ~/.oci/config, which you will need to create.
Once you have gone through the steps of generating your API signing key and setting up your configuration file, you can test that everything is working using:
ansible localhost -m oracle.oci.oci_object_storage_namespace_facts
As you can see, Ansible is set up, and our configuration is working correctly!
To pull the samples down, I used wget after making a directory to store them:
mkdir ansible
cd ansible
wget https://raw.githubusercontent.com/oracle/oci-ansible-collection/master/samples/database/autonomous_database/dedicated/sample.yaml
wget https://raw.githubusercontent.com/oracle/oci-ansible-collection/master/samples/database/autonomous_database/dedicated/teardown.yaml
You need to set OS variables or update the Ansible variables for the scripts to work. I find it easiest to create the OS variables this way:
export SAMPLE_COMPARTMENT_OCID=ocid1.compartment.oc1..a........teyo5ln6zl5p3ncgcpo7ur
export SAMPLE_OCPU_COUNT=.5
export SAMPLE_ADB_DISPLAY_NAME=ANSDED
export SAMPLE_DB_NAME=ANSDED
export SAMPLE_ADMIN_PASSWORD=OciOci2022##
export SAMPLE_DATA_STORAGE_SIZE_IN_GBS=75
export SAMPLE_IS_DEDICATED=true
export SAMPLE_CLOUD_AUTONOMOUS_VM_CLUSTER_ID=ocid1.cloudexadatainfrastructure.oc1.oc1.iad...gjwp2p
export SAMPLE_ACD_DISPLAY_NAME=ANSACD
These are the bare minimum variables that have to be set for the sample to work. Many other parameters can be set to customize the creation of the resources.
As of the time of writing this blog, more details can be found
here:
Run the sample using:
nohup ansible-playbook sample_dedicated.yaml &
This will run the process in the background in case our session times out and will create a file called nohup.out that we can review and watch the progress using:
tail -f nohup.out
Sample of the partial expected output:
After the script completes, you should see the below recap if everything was successful:
The creation script will take about 60 minutes, and the teardown about 40 minutes to complete.
As you can see, getting Ansible set up and running in your dedicated environment is an easy process, and the benefits of being able to script and automate your resource creation is substantial.
Source: oracle.com
0 comments:
Post a Comment