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

Add updates-clause to command and shell module #193

Open
UnitedMarsupials opened this issue May 15, 2021 · 0 comments
Open

Add updates-clause to command and shell module #193

UnitedMarsupials opened this issue May 15, 2021 · 0 comments

Comments

@UnitedMarsupials
Copy link

UnitedMarsupials commented May 15, 2021

Add updates clause to command and shell modules

Author: United Marsupials <@UnitedMarsupials>

Date: 20210-05-15

  • Status: New
  • Estimated time to implement: 1 week

Motivation

Make command and shell modules more useful

Problems

When a command (or shell) task is meant to modify a file -- in a way, for which no other tasks exist (beyond lineinfile or patch), there are following problems:

  • A status of the task is always "changed" by default, even when it made no changes.
  • There is no way to see the "diff" of the modified files -- without implementing multiple tasks for it.

Solution proposal

Similar to the already-present creates clause, the module could have an updates clause, which shall cause Ansible to diff the listed file(s) and to automatically set changed to False, if no changes actually took place.

    - name: Run the reports
      command: runreports.sh
        updates:
          - /prod/reports/sales.csv
          - /prod/reports/accounting.csv
  
    - name: Dump my table
      shell: isql -b > dump.txt
        args:
          stdin: |-
             SELECT * FROM MYTABLE
             go
        updates: dump.txt

Documentation (optional)

Parameter Choices/Defaults Comments
updates (path) A filename or glob pattern -- or a list of such. The task will be considered unchanged, if none of the listed files are modified. If "diff" is requested, these files will be compared to their older versions.
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