diff options
author | Andrew Klychkov <aaklychkov@mail.ru> | 2020-06-02 17:52:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 17:52:12 +0200 |
commit | 00ead98595577f110165d2c87c6c5c38c27b4b74 (patch) | |
tree | 8fc58fc0e99fd52c95bf19beacca6df3fce0ddc8 /test/integration/targets/systemd | |
parent | Update plugin_formatter to understand tagged version_added (#69797) (diff) | |
download | ansible-00ead98595577f110165d2c87c6c5c38c27b4b74.tar.xz ansible-00ead98595577f110165d2c87c6c5c38c27b4b74.zip |
systemd: should fail in check_mode when service not found on host (#68136)
* systemd: should fail in check_mode when service not found on host
Diffstat (limited to 'test/integration/targets/systemd')
-rw-r--r-- | test/integration/targets/systemd/defaults/main.yml | 1 | ||||
-rw-r--r-- | test/integration/targets/systemd/tasks/main.yml | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/test/integration/targets/systemd/defaults/main.yml b/test/integration/targets/systemd/defaults/main.yml new file mode 100644 index 0000000000..33063b86d9 --- /dev/null +++ b/test/integration/targets/systemd/defaults/main.yml @@ -0,0 +1 @@ +fake_service: nonexisting diff --git a/test/integration/targets/systemd/tasks/main.yml b/test/integration/targets/systemd/tasks/main.yml index a3078540ec..282988b356 100644 --- a/test/integration/targets/systemd/tasks/main.yml +++ b/test/integration/targets/systemd/tasks/main.yml @@ -47,4 +47,29 @@ - 'not systemd_test0.changed' - 'systemd_test0.state == "started"' + - name: the module must fail when a service is not found + systemd: + name: '{{ fake_service }}' + state: stopped + register: result + ignore_errors: yes + + - assert: + that: + - result is failed + - result is search("Could not find the requested service {{ fake_service }}") + + - name: the module must fail in check_mode as well when a service is not found + systemd: + name: '{{ fake_service }}' + state: stopped + register: result + check_mode: yes + ignore_errors: yes + + - assert: + that: + - result is failed + - result is search("Could not find the requested service {{ fake_service }}") + when: 'systemctl_check.rc == 0' |