IBM-Cloud / ansible-collection-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
70 stars 73 forks source link

ibm_cos_bucket_info fails with timeout when bucket does not exist #118

Open avmgithub opened 1 year ago

avmgithub commented 1 year ago

When using the following code below to check if a bucket exists, the code fails with a time out. I was expecting it to just return without an error:

- name: Check cos bucket Exists
   ibm_cos_bucket_info:
     bucket_name: "{{ cos_bucket_name }}"
     resource_instance_id: "{{ resource_info_output.resource.id }}"
     bucket_region: "{{ region }}"
     bucket_type: "{{ bucket_type }}"
#   # failed_when: 
#   #    - resource_cos_output.rc == 0
#   #    - '"ResourceCOSBucketDoesnotExist" not in resource_info_output.stderr'     
#   register: resource_cos_output

here is the error: Why does the error say its waiting to be created. I specifically asked for ibm_cos_bucket_info. not ibm_cos_bucket

TASK [Check cos bucket Exists] ***** task path: /Users/mendoza/projects/satellite/ansible/ansible-satellite/playbooks/location/create_cos_bucket.yaml:92 <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: mendoza <127.0.0.1> EXEC /bin/sh -c 'echo ~mendoza && sleep 0' <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /Users/mendoza/.ansible/tmp"&& mkdir "echo /Users/mendoza/.ansible/tmp/ansible-tmp-1694616526.831924-42898-87426550814838" && echo ansible-tmp-1694616526.831924-42898-87426550814838="echo /Users/mendoza/.ansible/tmp/ansible-tmp-1694616526.831924-42898-87426550814838" ) && sleep 0' Using module file /Users/mendoza/.ansible/collections/ansible_collections/ibm/cloudcollection/plugins/modules/ibm_cos_bucket_info.py <127.0.0.1> PUT /Users/mendoza/.ansible/tmp/ansible-local-42228wo8_272m/tmpm446kaiw TO /Users/mendoza/.ansible/tmp/ansible-tmp-1694616526.831924-42898-87426550814838/AnsiballZ_ibm_cos_bucket_info.py <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/mendoza/.ansible/tmp/ansible-tmp-1694616526.831924-42898-87426550814838/ /Users/mendoza/.ansible/tmp/ansible-tmp-1694616526.831924-42898-87426550814838/AnsiballZ_ibm_cos_bucket_info.py && sleep 0' <127.0.0.1> EXEC /bin/sh -c '/opt/homebrew/opt/python@3.10/bin/python3.10 /Users/mendoza/.ansible/tmp/ansible-tmp-1694616526.831924-42898-87426550814838/AnsiballZ_ibm_cos_bucket_info.py && sleep 0' <127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/mendoza/.ansible/tmp/ansible-tmp-1694616526.831924-42898-87426550814838/ > /dev/null 2>&1 && sleep 0' fatal: [localhost]: FAILED! => { "changed": false, "invocation": { "module_args": { "bucket_name": "xyz-cos-bucket-3", "bucket_region": "us-east", "bucket_type": "cross_region_location", "endpoint_type": null, "iaas_classic_api_key": null, "iaas_classic_username": null, "ibmcloud_api_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "region": "us-south", "resource_instance_id": "crn:v1:bluemix:public:cloud-object-storage:global:a/124e0fcd3dd24a6b85c047d50c8cdf74:5400262a-0e16-4e67-bfd5-c47728267cea::", "satellite_location_id": null } }, "msg": "", "rc": 1, "resource": { "_name": "ansible_20230913-094848", "_type": "ibm_cos_bucket", "target": "ibm_cos_bucket.ansible_20230913-094848" }, "stderr": "\nError: failed waiting for bucket xyz-cos-bucket-3 to be created, ResourceNotReady: exceeded wait attempts\n\n on ibm_cos_bucket_ansible_20230913-094848.tf line 1, in data \"ibm_cos_bucket\" \"ansible_20230913-094848\":\n 1: data ibm_cos_bucket \"ansible_20230913-094848\" {\n\n\n", "stderr_lines": [ "", "Error: failed waiting for bucket xyz-cos-bucket-3 to be created, ResourceNotReady: exceeded wait attempts", "", " on ibm_cos_bucket_ansible_20230913-094848.tf line 1, in data \"ibm_cos_bucket\" \"ansible_20230913-094848\":", " 1: data ibm_cos_bucket \"ansible_20230913-094848\" {", "", "" ], "stdout": "data.ibm_cos_bucket.ansible_20230913-094848: Refreshing state...\n", "stdout_lines": [ "data.ibm_cos_bucket.ansible_20230913-094848: Refreshing state..." ] }

PLAY RECAP *****