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

script executes in check mode #30676

Closed
rafernandez opened this issue Sep 21, 2017 · 1 comment · Fixed by #31852
Closed

script executes in check mode #30676

rafernandez opened this issue Sep 21, 2017 · 1 comment · Fixed by #31852
Assignees
Labels
affects_2.1 This issue/PR affects Ansible v2.1 affects_2.2 This issue/PR affects Ansible v2.2 affects_2.3 This issue/PR affects Ansible v2.3 affects_2.4 This issue/PR affects Ansible v2.4 affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. c:plugins/action module This issue/PR relates to a module. P2 Priority 2 - Issue Blocks Release support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Milestone

Comments

@rafernandez
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

module script

ANSIBLE VERSION
2.3.2.0
CONFIGURATION
OS / ENVIRONMENT

N/A

SUMMARY

In check mode, when a task with module script is executed, script is really executed on the node

STEPS TO REPRODUCE
cat playbook-test-script.yml 
- hosts: all
  tasks:
  - name: test module script
    script: touchTMP.sh
  - name: test module file
    file: path=/tmp/test-create-fic-with-mode-file state=touch mode=0777
cat touchTMP.sh 
#!/bin/bash
touch /tmp/test-create-fic-with-module-script
ansible-playbook -i localhost, -c local --check playbook-test-script.yml 

PLAY [all] ********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [localhost]

TASK [test module script] *****************************************************************************************************************************************************************************************
changed: [localhost]

TASK [test module file] *******************************************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=3    changed=2    unreachable=0    failed=0
EXPECTED RESULTS

0 files in /tmp

ACTUAL RESULTS

1 file in /tmp :

/tmp/test-create-fic-with-module-script
@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 21, 2017
@nitzmahone nitzmahone added affects_2.1 This issue/PR affects Ansible v2.1 affects_2.2 This issue/PR affects Ansible v2.2 affects_2.4 This issue/PR affects Ansible v2.4 affects_2.5 This issue/PR affects Ansible v2.5 c:plugins/action and removed needs_triage Needs a first human triage before being processed. labels Sep 21, 2017
@nitzmahone nitzmahone modified the milestones: 2.4.0, 2.5.0 Sep 21, 2017
@nitzmahone nitzmahone changed the title The script module execute script in check mode script and raw execute in check mode Sep 21, 2017
@nitzmahone nitzmahone changed the title script and raw execute in check mode script executes in check mode Sep 21, 2017
@nitzmahone nitzmahone added the P2 Priority 2 - Issue Blocks Release label Sep 21, 2017
@nitzmahone
Copy link
Member

Tested back to 1.9- this has apparently never been properly skipped in check_mode... Wow.

@samdoran samdoran self-assigned this Oct 17, 2017
@samdoran samdoran added this to TODO: Nice to have in 2.4.x Blocker List Oct 26, 2017
samdoran added a commit to samdoran/ansible that referenced this issue Oct 26, 2017
@bcoca bcoca moved this from Nice to have to Blocker in 2.4.x Blocker List Nov 10, 2017
@bcoca bcoca removed this from Blocker in 2.4.x Blocker List Nov 10, 2017
nitzmahone pushed a commit that referenced this issue Nov 13, 2017
* Do not run script in check mode

Fixes #30676

* Reformat script integration test

* Add integration tests for check mode of script module

* Fix name on test

* Cleanup temp file

* win_script integration test syntaxt changes

* Add check mode tests for win_script

* Use proper variable in test

* Fail if source file does not exist

* Verify script is accessible and don't copy in check mode

Use shlex to properly split shell arguments, though a path with spaces in it still needs to be quoted in the playbook.
Add note to docs describing such.
Improve error message if file is not found indicating there may be a space in the path.

* Properly encode path now that path is split using shlex

* Allow for spaces in both path and script name

* Add unicode character test to Linux script tests

* Add Linux test for space in path to script
samdoran added a commit that referenced this issue Nov 14, 2017
* Do not run script in check mode

Fixes #30676

* Reformat script integration test

* Add integration tests for check mode of script module

* Fix name on test

* Cleanup temp file

* win_script integration test syntaxt changes

* Add check mode tests for win_script

* Use proper variable in test

* Fail if source file does not exist

* Verify script is accessible and don't copy in check mode

Use shlex to properly split shell arguments, though a path with spaces in it still needs to be quoted in the playbook.
Add note to docs describing such.
Improve error message if file is not found indicating there may be a space in the path.

* Properly encode path now that path is split using shlex

* Allow for spaces in both path and script name

* Add unicode character test to Linux script tests

* Add Linux test for space in path to script

(cherry picked from commit ea3638b)
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.1 This issue/PR affects Ansible v2.1 affects_2.2 This issue/PR affects Ansible v2.2 affects_2.3 This issue/PR affects Ansible v2.3 affects_2.4 This issue/PR affects Ansible v2.4 affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. c:plugins/action module This issue/PR relates to a module. P2 Priority 2 - Issue Blocks Release support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants