ansible-collections / ansible-collections/google.cloud

gcp_storage_object not idempotent

Open
#492 1 comment 1 reaction 0 assignees View on GitHub
stale
Dominant language
Python
Stars
105
Forks
144
Avg merge
5d 10h
Merged PRs (30d)
4

Description

##### SUMMARY

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME

gcp_storage_object

##### ANSIBLE VERSION

```paste below
ansible [core 2.12.7]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/jlosito/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.10/site-packages/ansible
ansible collection location = /home/jlosito/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.5 (main, Jun 9 2022, 00:00:00) [GCC 12.1.1 20220507 (Red Hat 12.1.1-1)]
jinja version = 3.0.3
libyaml = True
```

##### COLLECTION VERSION

```paste below
# ansible-galaxy collection list google.cloud

Collection Version
------------ -------
google.cloud 1.0.2
```

Technically, we're using commit hash `ec093086ab2b7ab203e23e1d45ba7944a737f7b8` for a feature that was added around labels and inventory generation.

##### STEPS TO REPRODUCE

Upload a file to a bucket in GCS, then try to upload the same exact file to the same path in the same GCS bucket. You should notice that the module will still upload the file on the second run.

```yaml
- name: Generate file to upload
ansible.builtin.copy:
content: "hello"
dest: /tmp/my_file.txt
owner: root
group: root
mode: 0400
delegate_to: localhost

- name: Upload example object to gcs
google.cloud.gcp_storage_object:
action: upload
auth_kind: serviceaccount
bucket: my_bucket
dest: my_file.txt
src: /tmp/my_file.txt
project: my-gcp-project
service_account_file: ~/.gcp/my_service_account.json
delegate_to: localhost
```

##### EXPECTED RESULTS

The put only uploads the file when there's a difference between the src file and the dest object which is already uploaded to GCS. For example, the [amazon.aws.aws_s3](https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_s3_module.html#parameter-overwrite) module has the `overwrite: different` parameter.

##### ACTUAL RESULTS

The task will always so change, instead of only uploading the file when necessary, when there should be a change to the object.

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementation and tests for the gcp_storage_object module, then reproduce the upload twice with the provided playbook against the same GCS object. The change is done when the second run reports no change and uploads only when the source and destination differ.

Written by the indexing model from the issue text.

Assessment

Tech stack
gcp, python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.