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

make check_mode integration test fails #13418

Closed
trinitronx opened this issue Dec 3, 2015 · 3 comments
Closed

make check_mode integration test fails #13418

trinitronx opened this issue Dec 3, 2015 · 3 comments
Labels
bug This issue/PR relates to a bug.
Milestone

Comments

@trinitronx
Copy link

I stumbled across this when trying to implement a testing, CI, & CD pipeline for my fork of the old unmaintained Ansible Base Docker images (trinitronx/ansible-docker-base). When running the make check_mode integration test playbook, it fails with errors:

[root@9195d2eae5e1 integration]# make check_mode
ansible-playbook check_mode.yml -i inventory -e @integration_config.yml  -v --check
No config file found; using defaults

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [testhost]

TASK [test_always_run : run a command while in check mode] *********************
changed: [testhost] => {"changed": true, "cmd": "echo \"running\"", "delta": "0:00:00.060007", "end": "2015-12-03 18:17:13.285784", "rc": 0, "start": "2015-12-03 18:17:13.225777", "stderr": "", "stdout": "running", "stdout_lines": ["running"], "warnings": []}

TASK [test_always_run : assert that the command was run] ***********************
ok: [testhost] => {"changed": false, "msg": "all assertions passed"}

TASK [prepare_tests : clean out the test directory] ****************************
changed: [testhost] => {"changed": true, "path": "/root/ansible_testing", "state": "absent"}

TASK [prepare_tests : create the test directory] *******************************
changed: [testhost] => {"changed": true, "gid": 0, "group": "root", "mode": "0755", "owner": "root", "path": "/root/ansible_testing", "size": 4096, "state": "directory", "uid": 0}

TASK [test_check_mode : fill in a basic template in check mode] ****************
changed: [testhost] => {"changed": true}

TASK [test_check_mode : verify that the file was marked as changed in check mode] ***
ok: [testhost] => {"changed": false, "msg": "all assertions passed"}

TASK [test_check_mode : Actually create the file] ******************************
changed: [testhost] => {"changed": true}

TASK [test_check_mode : fill in a basic template in check mode] ****************
changed: [testhost] => {"changed": true}

TASK [test_check_mode : verify that the file was marked as not changed in check mode] ***
fatal: [testhost]: FAILED! => {"assertion": "template_result2.changed == false", "changed": false, "evaluated_to": false, "failed": true}

PLAY RECAP *********************************************************************
testhost                   : ok=9    changed=6    unreachable=0    failed=1

make: *** [check_mode] Error 2

You can also see the error on lines 7523-7533 of this Travis CI test log.

It appears that when the playbook is first run in --check-mode, it simulates writing a template file and asserts that the file is changed, but is not actually written. Then the template module is run with always_run: True to actually write out a file, then is run again, this time without always_run: True. Finally, the playbook asserts that the task was marked as "not changed" in order to test that the template module (run in --check-mode) knows the file does not need to be changed when it is already existing on the filesystem.

The failure seems to be because the file does not exist after the first template run with always_run: True. The odd thing is that the make check_mode playbook also runs the test_always_run role, which indeed does test that always_run: yes on a command module does actually run the command.

This was run against current devel branch HEAD: b85e6e0

@jimi-c jimi-c added this to the v2 milestone Dec 3, 2015
@trinitronx
Copy link
Author

Note: I've removed the broken tests from my Travis CI build for now just to get it working... but there are more than just check_mode that I had to remove ;-)

@jimi-c
Copy link
Member

jimi-c commented Dec 8, 2015

Interesting, so this is failing because the task above the one that fails is not properly honoring the always_run: True option. Digging into why...

@jimi-c
Copy link
Member

jimi-c commented Dec 8, 2015

Closing This Ticket

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

bcoca added a commit that referenced this issue Dec 8, 2015
bcoca added a commit that referenced this issue Dec 8, 2015
@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 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants