Skip to content

ibm_cos_bucket is not idempotent #65

Open
@treytabner

Description

@treytabner

According to https://github.com/IBM-Cloud/ansible-collection-ibm/blob/master/docs/ibm_cos_bucket.rst, the ibm_cos_bucket module supports idempotency, but it doesn't look like it's working currently. Here is my test playbook:

---
- name: Create bucket
  hosts: localhost
  collections:
    - ibm.cloudcollection
  tasks:
    - name: create cos bucket
      ibm_cos_bucket:
        bucket_name: "randombucket128372187382173455467894"
        resource_instance_id: "crn:v1:bluemix:public:cloud-object-storage:global:a/5bd765d6cf2eac993e8b3749af9f9b2f:3ba4b8d4-2587-4cb7-abcb-20c92abd7b64::"
        storage_class: "standard"
        region_location: "us-south"

And when I first run the playbook, the bucket gets created:

TASK [create cos bucket] ***********************************************************************************************************************************
task path: /home/trey/test/test.yml:7
changed: [localhost] => {"changed": true, "rc": 0, "resource": {"activity_tracking": [], "allowed_ip": null, "archive_rule": [], "bucket_name": "randombucket128372187382173455467894", "crn": "crn:v1:bluemix:public:cloud-object-storage:global:a/5bd765d6cf2eac993e8b3749af9f9b2f:3ba4b8d4-2587-4cb7-abcb-20c92abd7b64:bucket:randombucket128372187382173455467894", "cross_region_location": null, "endpoint_type": "public", "expire_rule": [], "force_delete": true, "id": "crn:v1:bluemix:public:cloud-object-storage:global:a/5bd765d6cf2eac993e8b3749af9f9b2f:3ba4b8d4-2587-4cb7-abcb-20c92abd7b64:bucket:randombucket128372187382173455467894:meta:rl:us-south:public", "key_protect": null, "metrics_monitoring": [], "object_versioning": [], "region_location": "us-south", "resource_instance_id": "crn:v1:bluemix:public:cloud-object-storage:global:a/5bd765d6cf2eac993e8b3749af9f9b2f:3ba4b8d4-2587-4cb7-abcb-20c92abd7b64::", "retention_rule": [], "s3_endpoint_private": "s3.private.us-south.cloud-object-storage.appdomain.cloud", "s3_endpoint_public": "s3.us-south.cloud-object-storage.appdomain.cloud", "single_site_location": null, "storage_class": "standard", "timeouts": null}, "stderr": "", "stderr_lines": [], "stdout": "ibm_cos_bucket.ansible_20210621-160422: Creating...\nibm_cos_bucket.ansible_20210621-160422: Creation complete after 5s [id=crn:v1:bluemix:public:cloud-object-storage:global:a/5bd765d6cf2eac993e8b3749af9f9b2f:3ba4b8d4-2587-4cb7-abcb-20c92abd7b64:bucket:randombucket128372187382173455467894:meta:rl:us-south:public]\n\nApply complete! Resources: 1 added, 0 changed, 0 destroyed.\n", "stdout_lines": ["ibm_cos_bucket.ansible_20210621-160422: Creating...", "ibm_cos_bucket.ansible_20210621-160422: Creation complete after 5s [id=crn:v1:bluemix:public:cloud-object-storage:global:a/5bd765d6cf2eac993e8b3749af9f9b2f:3ba4b8d4-2587-4cb7-abcb-20c92abd7b64:bucket:randombucket128372187382173455467894:meta:rl:us-south:public]", "", "Apply complete! Resources: 1 added, 0 changed, 0 destroyed."]}

When I run it a second time:

TASK [create cos bucket] ***********************************************************************************************************************************
task path: /home/trey/barge-deploy/test.yml:7
fatal: [localhost]: FAILED! => {"changed": false, "msg": "", "rc": 1, "resource": {"_name": "ansible_20210621-160547", "_type": "ibm_cos_bucket", "target": "ibm_cos_bucket.ansible_20210621-160547"}, "stderr": "\nError: BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.\n\tstatus code: 409, request id: f3f6d093-381d-4c39-bf77-ad03c6054e38, host id: \n\n  on ibm_cos_bucket_ansible_20210621-160547.tf line 1, in resource \"ibm_cos_bucket\" \"ansible_20210621-160547\":\n   1: resource ibm_cos_bucket \"ansible_20210621-160547\" {\n\n\n", "stderr_lines": ["", "Error: BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.", "\tstatus code: 409, request id: f3f6d093-381d-4c39-bf77-ad03c6054e38, host id: ", "", "  on ibm_cos_bucket_ansible_20210621-160547.tf line 1, in resource \"ibm_cos_bucket\" \"ansible_20210621-160547\":", "   1: resource ibm_cos_bucket \"ansible_20210621-160547\" {", "", ""], "stdout": "ibm_cos_bucket.ansible_20210621-160547: Creating...\n", "stdout_lines": ["ibm_cos_bucket.ansible_20210621-160547: Creating..."]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions