/
list_objects.yaml
36 lines (33 loc) · 1.24 KB
/
list_objects.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- name: List objects from all the buckets
hosts: localhost
collections:
- oracle.oci
vars:
# common vars
sample_bucket_name: "sample_bucket"
sample_object_name: "sample_object"
#########################################
# Tenancy specific configuration
# *Note* - Override the following variables based on your tenancy
# or set a valid value for the corresponding environment variable
#########################################
compartment_id: "{{ lookup('env', 'SAMPLE_COMPARTMENT_OCID') }}"
namespace_name: "{{ lookup('env', 'SAMPLE_OBJECT_NS_NAME') }}"
tasks:
- name: Get all the buckets in the namespace
oci_object_storage_bucket_facts:
namespace_name: "{{ namespace_name }}"
compartment_id: "{{ compartment_id }}"
register: ocibuckets
- name: Get all objects from all the buckets
oci_object_storage_object_facts:
namespace_name: "{{ namespace_name }}"
bucket_name: "{{ item.name }}"
with_items: "{{ ocibuckets.buckets }}"
register: output
- name: Print objects list
debug:
msg: 'Bucket: {{item.item.name}}, Objects: {{item.objects}}'
loop: "{{output.results}}"
loop_control:
label: "{{item.item.name}}"