oracle / oci-ansible-collection

Oracle Cloud Infrastructure Ansible Collection provides an easy way to provision and manage resources in Oracle Cloud using Ansible.
https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/ansible.htm
Other
173 stars 97 forks source link

Module `oci_object_storage_object` does not support check mode #276

Open jeliker opened 7 months ago

jeliker commented 7 months ago

Issue Report

When executing playbook with --check flag, oci_object_storage_object is throwing error because destination folder does not exist. This is true because --check is preventing the destination folder from being created (i.e. module ansible.builtin.file is properly respecting check-mode so not creating the folder).

Expected behavior When --check flag is set I expect oci_object_storage_object module to not actually download the object being referenced.

Environment

Ansible playbook to reproduce the issue

---
- name: Download
  hosts: all

  tasks:
    - name: Create download folder
      file:
        path: "{{ download_folder }}"
        state: directory
      delegate_to: localhost

    - name: Download installer
      oracle.oci.oci_object_storage_object:
        bucket_name: server-build
        object_name: "{{ item.object_name }}"
        dest: "{{ download_folder }}/{{ item.local_name }}"
        auth_type: api_key
        namespace_name: "{{ os_namespace.namespace }}"
      delegate_to: localhost
      with_items: "{{ installers }}"
$ ansible-playbook -i inventories/remote --diff --check books/download.yml

. . . 

TASK [Create download folder] ********************************************************************************************************
--- before
+++ after
@@ -1,4 +1,4 @@
 {
     "path": "installers",
-    "state": "absent"
+    "state": "directory"
 }

changed: [app1.sub1.vcn1.oraclevcn.com -> localhost]

TASK [Download installers] ***********************************************************************************************************
failed: [app1.sub1.vcn1.oraclevcn.com -> localhost] (item={'key': 'app1', 'local_name': 'app1-linux.rpm', 'object_name': 'app1-9.1.1.x86_64.rpm', 'sha1sum': 'e7df4c5fe051d0589b62b309dd206908bc02bf4d'}) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "splunk", "local_name": "app1-linux.rpm", "object_name": "app1-9.1.1.x86_64.rpm", "sha1sum": "e7df4c5fe051d0589b62b309dd206908bc02bf4d"}, "msg": "Error opening/creating the dest file: [Errno 2] No such file or directory: 'installers/app1-linux.rpm'", "troubleshooting_tips": "Refer to troubleshooting guide https://docs.oracle.com/en-us/iaas/tools/oci-ansible-collection/latest/guides/troubleshooting-guide.html"}

PLAY RECAP ************************************************************************************************************************************
app1.sub1.vcn1.oraclevcn.com : ok=0    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0