Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy/Template modules inconsistency #212

Open
resmo opened this issue Oct 8, 2024 · 0 comments
Open

Copy/Template modules inconsistency #212

resmo opened this issue Oct 8, 2024 · 0 comments

Comments

@resmo
Copy link

resmo commented Oct 8, 2024

Proposal: Make copy/template modules more consistent

Author: René Moser <@resmo> IRC: resmo

Date: 2024-10-08

  • Status: New
  • Proposal type: core module
  • Targeted release: ?

Motivation

I noticed an inconsistency when using --check mode with the copy (and template) module.

Returns are not returned in check mode if changed=true on an update scenario.
Docs for copy's returns mentions returned on: success.

Problems

we have an existing file on the target, we verify with --check, changed=False returned
--> returns looks as expected.

 $ ansible -m copy -a 'src=dummy.txt dest=/tmp/dummy.txt' demo-web1 --check 
demo-web1 | SUCCESS => {
    "changed": false,
    "checksum": "0fb00cb451fba290ac6c613cdaaf0a687145c752",
    "dest": "/tmp/dummy.txt",
    "gid": 0,
    "group": "root",
    "mode": "0644",
    "owner": "root",
    "path": "/tmp/dummy.txt",
    "size": 22,
    "state": "file",
    "uid": 0
}

Then we make some changes:

$ echo "some changes" >> dummy.txt

Run again with --check, this time we have changed=true as expected but no other returns?

$ ansible -m copy -a 'src=dummy.txt dest=/tmp/dummy.txt' demo-web1 --check 
demo-web1 | CHANGED => {
    "changed": true
}

I would have expected returns, because there is an existing file.

Solution proposal

  • always return keys, also in check mode.
  • scenario create in check mode: return with none (N/A?) values
  • scenario update in check mode: return with values of existing, non-modified file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant