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 https://github.com/oracle/oci-ansible-modules.git cd oci-ansible-modules ./install.py 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 tasks: - name: List bucket facts oci_bucket_facts: namespace_name: 'mxlxxhxtxlsxntxrnxtxxnxl' compartment_id: 'ocid1.compartment.oc1..aaaaaaaa3sz43qrfhsjmbibsrc6e7c2ftlt53gfnzifvlow2yoz7hk3ni2jq' register: result - name: Dump result debug: 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/javier.mugueta@oracle.com", "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/javier.mugueta@oracle.com", "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! 🙂