From e0bdb502e34237ffccca53e36a264e6a3b6b6870 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Tue, 16 Aug 2016 20:39:23 -0700 Subject: [PATCH] raw now returns changed: true (#17112) for consistency w/ shell/command/script "non-idempotent" modules. Updated tests, changelog. --- CHANGELOG.md | 1 + lib/ansible/plugins/action/raw.py | 2 ++ test/integration/roles/test_win_raw/tasks/main.yml | 10 +++++----- test/integration/test_connection.yml | 5 ++++- test/integration/test_connection_winrm.yml | 5 ++++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c7af9b1272..bc23e48bd4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Ansible Changes By Release * Added the `listen` feature for modules. This feature allows tasks to more easily notify multiple handlers, as well as making it easier for handlers from decoupled roles to be notified. * Added support for binary modules +* `raw` now returns `changed: true` to be consistent with shell/command/script modules. Add `changed_when: false` to `raw` tasks to restore the pre-2.2 behavior if necessary. * The service module has been changed to use system specific modules if they exist and fallback to the old service module if they cannot be found or detected. * Several Windows facts were modified or renamed for consistency with their Unix counterparts, and many new facts were added. If your playbooks rely on any of the following keys, please ensure they are using the correct key names and/or values: - ansible_date_time.date (changed to use yyyy-mm-dd format instead of default system-locale format) diff --git a/lib/ansible/plugins/action/raw.py b/lib/ansible/plugins/action/raw.py index 5209b37a234..cdafee34c6f 100644 --- a/lib/ansible/plugins/action/raw.py +++ b/lib/ansible/plugins/action/raw.py @@ -40,4 +40,6 @@ class ActionModule(ActionBase): executable = self._task.args.get('executable', False) result.update(self._low_level_execute_command(self._task.args.get('_raw_params'), executable=executable)) + result['changed'] = True + return result diff --git a/test/integration/roles/test_win_raw/tasks/main.yml b/test/integration/roles/test_win_raw/tasks/main.yml index 30c1a75e6b3..6e4c9da064b 100644 --- a/test/integration/roles/test_win_raw/tasks/main.yml +++ b/test/integration/roles/test_win_raw/tasks/main.yml @@ -27,7 +27,7 @@ - "getmac_result.stdout" - "not getmac_result.stderr" - "not getmac_result|failed" - - "not getmac_result|changed" + - "getmac_result|changed" - name: run ipconfig with /all argument raw: ipconfig /all @@ -41,7 +41,7 @@ - "'Physical Address' in ipconfig_result.stdout" - "not ipconfig_result.stderr" - "not ipconfig_result|failed" - - "not ipconfig_result|changed" + - "ipconfig_result|changed" - name: run ipconfig with invalid argument raw: ipconfig /badswitch @@ -55,7 +55,7 @@ - "ipconfig_invalid_result.stdout" # ipconfig displays errors on stdout. - "not ipconfig_invalid_result.stderr" - "ipconfig_invalid_result|failed" - - "not ipconfig_invalid_result|changed" + - "ipconfig_invalid_result|changed" - name: run an unknown command raw: uname -a @@ -69,7 +69,7 @@ - "not unknown_result.stdout" - "unknown_result.stderr" # An unknown command displays error on stderr. - "unknown_result|failed" - - "not unknown_result|changed" + - "unknown_result|changed" - name: run a command that takes longer than 60 seconds raw: Start-Sleep -s 75 @@ -82,7 +82,7 @@ - "not sleep_command.stdout" - "not sleep_command.stderr" - "not sleep_command|failed" - - "not sleep_command|changed" + - "sleep_command|changed" - name: run a raw command with key=value arguments raw: echo wwe=raw diff --git a/test/integration/test_connection.yml b/test/integration/test_connection.yml index 27f24aafd6b..757254b4f1e 100644 --- a/test/integration/test_connection.yml +++ b/test/integration/test_connection.yml @@ -9,7 +9,10 @@ raw: echo 汉语 register: command - name: check output of raw with unicode arg and output - assert: { that: "'汉语' in command.stdout" } + assert: + that: + - "'汉语' in command.stdout" + - command | changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules ### copy local file with unicode filename and content diff --git a/test/integration/test_connection_winrm.yml b/test/integration/test_connection_winrm.yml index 76e02a9e2db..edd25242a4e 100644 --- a/test/integration/test_connection_winrm.yml +++ b/test/integration/test_connection_winrm.yml @@ -9,7 +9,10 @@ raw: echo 汉语 register: command - name: check output of raw with unicode arg and output - assert: { that: "'汉语' in command.stdout" } + assert: + that: + - "'汉语' in command.stdout" + - command | changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules ### copy local file with unicode filename and content