Ansible for Oracle Cloud Infrastructure OCI

Today a short recipe for Ansible in Oracle Cloud (OCI)

Install it:

brew update
brew install openssl
brew upgrade openssl
brew install python
pip install virtualenv
virtualenv oci_sdk_env
source oci_sdk_env/bin/activate
pip install oci
pip install oci==2.1.3
pip install --upgrade pip
pip install ansible
git clone
cd oci-ansible-modules
pip install idna

Prepare it:

Create test.yml file and put your own cloud account values in bold as follows:

- name : List summary of existing buckets in OCI object storage
  connection: local
  hosts: localhost
    - name: List bucket facts
         namespace_name: 'mxlxxhxtxlsxntxrnxtxxnxl'
         compartment_id: 'ocid1.compartment.oc1..aaaaaaaa3sz43qrfhsjmbibsrc6e7c2ftlt53gfnzifvlow2yoz7hk3ni2jq'
      register: result
    - name: Dump result
        msg: '{{result}}'

Test it:

ansible-plabook test.yml
(oci_sdk_env) MacBook-Pro:oci-ansible-modules javiermugueta$ ansible-playbook test.yml 
 [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
 [WARNING]: No inventory was parsed, only implicit localhost is available
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [List summary of existing buckets in OCI object storage] ******
TASK [Gathering Facts] *********************************************
ok: [localhost]
TASK [List bucket facts] *******************************************
ok: [localhost]
TASK [Dump result] *************************************************
ok: [localhost] => {
    "msg": {
        "buckets": [
                "compartment_id": "ocid1.compartment.oc1..aaaaaaaa3sz43qrfhsjmbibsrc6e7c2ftlt53gfnzifvlow2yoz7hk3ni2jq", 
                "created_by": "ocid1.saml2idp.oc1..aaaaaaaavw5k65pd5empwbumrd7q6puushecinoot5whdnuvjzgf2x2cjy7q/", 
                "defined_tags": null, 
                "etag": "b8376915-101d-4edc-9f16-c7c5f88b50c2", 
                "freeform_tags": null, 
                "name": "xxx", 
                "namespace": "xxx", 
                "time_created": "2019-04-05T22:05:18.974000+00:00"
                "compartment_id": "ocid1.compartment.oc1..aaaaaaaa3sz43qrfhsjmbibsrc6e7c2ftlt53gfnzifvlow2yoz7hk3ni2jq", 
                "created_by": "ocid1.saml2idp.oc1..aaaaaaaavw5k65pd5empwbumrd7q6puushecinoot5whdnuvjzgf2x2cjy7q/", 
                "defined_tags": null, 
                "etag": "cf309d1c-eb85-4247-90e6-222a87933a90", 
                "freeform_tags": null, 
                "name": "prueba", 
                "namespace": "xxx", 
                "time_created": "2019-04-08T20:37:03.937000+00:00"
        "changed": false, 
        "failed": false
PLAY RECAP *********************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0

Hope it helps! 🙂




javier mugueta View All →

Me and my circumstance

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: