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

[WIP] Fix changes status and return diff information when state=touch and check_mode is set #56174

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
4 participants
@DSNortsev
Copy link

commented May 7, 2019

SUMMARY

Fixes #50452

  • Add check_model parameter to update_timestamp_for_file function and the file timestamp
    only updates when check_mode is set to False (default option)
  • Changed is set to TRUE if file does not exist or the access_time and modification_time
    option are not set to preserve
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

file

ADDITIONAL INFORMATION

Playbook:

---
- hosts: localhost
  connection: local
  tasks:

  - name: Ensure file for specifications
    file:
      path: /tmp/test
      state: touch

Playbook when access_time and modification_time are preserve:

---
- hosts: localhost
  connection: local
  gather_facts: no
  tasks:
    - name: Ensure file for specifications
      file:
        path: /tmp/test
        state: touch
        access_time: preserve
        modification_time: preserve

Before Fix:

ok: [localhost] => {
    "changed": false,
    "dest": "/tmp/test",
    "gid": 1001,
    "group": "dmitry",
    "invocation"

After Fix if file does not exist:

changed: [localhost] => {
    "changed": true,
    "dest": "/tmp/test",
    "invocation": {
        "module_args":

After Fix if file exists:

changed: [localhost] => {
    "changed": true,
    "dest": "/tmp/test",
    "diff": {
        "after": {
            "atime": 1557243232.714623,
            "mtime": 1557243232.714623,
            "path": "/tmp/test",
            "state": "touch"
        },
        "before": {
            "atime": 1557243223.6023092,
            "mtime": 1557243223.6023092,
            "path": "/tmp/test",
            "state": "file"
        }
    },

After fix if acccess_time and modification_time are set to preserve:

    "changed": false,
    "dest": "/tmp/test",
    "gid": 1001,
    "group": "dmitry",
    "invocation":
Fix changes status and return diff information when state=touch and c…
…heck_mode is set

Fixes #50452

* Add check_model parameter to update_timestamp_for_file function and the file timestamp
  only updates when check_mode is set to False (default option)
* Changed is set to TRUE if file does not exist or the access_time and modification_time
  option are not set to preserve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.