OCI: ansible setup on OL6.9

Relevant document is here and here.

Not that Ansible needs Python 2.7+.

How to install (root)

Install should probably be along these lines on OL6.x. It is better to install in such a way that it can cohabit with multiple python versions.

yum install python27 python33 git
alternatives --install /usr/bin/python python /usr/bin/python2.7 2
alternatives --install /usr/bin/python python /usr/bin/python3.3 1
scl enable python27 bash
pip2 install oci
pip2 install ansible
git clone https://github.com/oracle/oci-ansible-modules.git
cd oci-ansible-modules
./install.py

Sample usage

#1 Switch to the python27 context

scl enable python2.7 bash

#2 Configure the file $HOME/.oci/config with a similar content

[DEFAULT]
user=ocid1.user.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxa
fingerprint=xxxxxxxxxxxxxx
key_file=~/.ssh/cloudadmin.pem
tenancy=ocid1.tenancy.oc1..axxxx 
region=eu-frankfurt-1

#3 Configure a sample list_buckets.yml file with a similar content:

- name : List summary of existing buckets in OCI object storage
 connection: local
 hosts: localhost
 tasks:
 - name: List bucket facts
 oci_bucket_facts:
 namespace_name: '<tenant>'
 compartment_id: 'ocid1.tenancy.oc1..xxxx'
 register: result
 - name: Dump result
 debug: 
 msg: '{{result}}'

#4 Execute the script

ansible-playbook list_buckets.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": "xxxxx", 
 "created_by": "xxxxx", 
 "defined_tags": null, 
 "etag": "xxxxx", 
 "freeform_tags": null, 
 "name": "xxx", 
 "namespace": "xxxx", 
 "time_created": "xxxx"
 }, 
 ], 
 "changed": false, 
 "failed": false
 }
}

PLAY RECAP *****************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0