{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/45275","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/45275/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/45275/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/45275/events","html_url":"https://github.com/ansible/ansible/issues/45275","id":357559138,"node_id":"MDU6SXNzdWUzNTc1NTkxMzg=","number":45275,"title":"Conditional 'is skipped' always evaluates to false.","user":{"login":"jdavid5815","id":29729907,"node_id":"MDQ6VXNlcjI5NzI5OTA3","avatar_url":"https://avatars1.githubusercontent.com/u/29729907?v=4","gravatar_id":"","url":"https://api.github.com/users/jdavid5815","html_url":"https://github.com/jdavid5815","followers_url":"https://api.github.com/users/jdavid5815/followers","following_url":"https://api.github.com/users/jdavid5815/following{/other_user}","gists_url":"https://api.github.com/users/jdavid5815/gists{/gist_id}","starred_url":"https://api.github.com/users/jdavid5815/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdavid5815/subscriptions","organizations_url":"https://api.github.com/users/jdavid5815/orgs","repos_url":"https://api.github.com/users/jdavid5815/repos","events_url":"https://api.github.com/users/jdavid5815/events{/privacy}","received_events_url":"https://api.github.com/users/jdavid5815/received_events","type":"User","site_admin":false},"labels":[{"id":835286067,"node_id":"MDU6TGFiZWw4MzUyODYwNjc=","url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.6","name":"affects_2.6","color":"ededed","default":false},{"id":785271699,"node_id":"MDU6TGFiZWw3ODUyNzE2OTk=","url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":503572087,"node_id":"MDU6TGFiZWw1MDM1NzIwODc=","url":"https://api.github.com/repos/ansible/ansible/labels/needs_triage","name":"needs_triage","color":"0e8a16","default":false},{"id":383076471,"node_id":"MDU6TGFiZWwzODMwNzY0NzE=","url":"https://api.github.com/repos/ansible/ansible/labels/python3","name":"python3","color":"fbca04","default":false},{"id":636352796,"node_id":"MDU6TGFiZWw2MzYzNTI3OTY=","url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-06T08:57:31Z","updated_at":"2018-09-06T14:21:44Z","closed_at":"2018-09-06T14:21:44Z","author_association":"NONE","body":"<!--- Verify first that your issue is not already reported on GitHub -->\r\n<!--- Also test if the latest release and devel branch are affected too -->\r\n<!--- Complete *all* sections as described, this form is processed automatically -->\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly below -->\r\nThe conditional \"is skipped\" does not work. It is (poorly) documented [here](https://docs.ansible.com/ansible/2.6/user_guide/playbooks_conditionals.html).\r\n##### ISSUE TYPE\r\n- Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!--- Write the short name of the module, plugin, task or feature below -->\r\njinja2/python conditionals\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \"ansible --version\" between quotes -->\r\n```paste below\r\nansible 2.6.3\r\n  config file = /Users/jdavid/.ansible.cfg\r\n  configured module search path = ['/Users/jdavid/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible\r\n  executable location = /usr/local/bin/ansible\r\n  python version = 3.6.5 (default, Apr 25 2018, 14:23:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]\r\n```\r\n\r\n##### CONFIGURATION\r\n<!--- Paste verbatim output from \"ansible-config dump --only-changed\" between quotes -->\r\n```paste below\r\nansible 2.6.3\r\n  config file = /Users/jdavid/.ansible.cfg\r\n  configured module search path = ['/Users/jdavid/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible\r\n  executable location = /usr/local/bin/ansible\r\n  python version = 3.6.5 (default, Apr 25 2018, 14:23:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]\r\nTearsInRain.local:/Users/jdavid/BAC/ansible$ ansible-config dump --only-changed\r\nESC[0;33mANSIBLE_COW_SELECTION(/Users/jdavid/.ansible.cfg) = randomESC[0m\r\nESC[0;33mANSIBLE_COW_WHITELIST(/Users/jdavid/.ansible.cfg) = ['bud-frogs', 'bunny', 'cheese', 'daemon', 'default', 'dragon', 'elephant-in-snake', 'elephant', 'eyes', '\\\\\\nhellokitty', 'kitty', 'luke-koala', 'meow', 'milk', 'moofasa', 'moose', 'ren', 'sheep', 'small', 'stegosaurus', '\\\\\\nstimpy', 'supermilker', 'three-eyes', 'turkey', 'turtle', 'tux', 'udder', 'vader-koala', 'vader', 'www']ESC[0m\r\nESC[0;33mANSIBLE_NOCOWS(/Users/jdavid/.ansible.cfg) = FalseESC[0m\r\nESC[0;33mANSIBLE_PIPELINING(/Users/jdavid/.ansible.cfg) = TrueESC[0m\r\nESC[0;33mANSIBLE_SSH_ARGS(/Users/jdavid/.ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=5mESC[0m\r\nESC[0;33mDEFAULT_CALLBACK_WHITELIST(/Users/jdavid/.ansible.cfg) = ['timer', 'profile_tasks']ESC[0m\r\nESC[0;33mDEFAULT_FORKS(/Users/jdavid/.ansible.cfg) = 20ESC[0m\r\nESC[0;33mDEFAULT_HASH_BEHAVIOUR(/Users/jdavid/.ansible.cfg) = mergeESC[0m\r\nESC[0;33mDEFAULT_HOST_LIST(/Users/jdavid/.ansible.cfg) = ['/etc/ansible/hosts']ESC[0m\r\nESC[0;33mDEFAULT_LOCAL_TMP(/Users/jdavid/.ansible.cfg) = /tmp/ansible-local-16300zvo884ypESC[0m\r\nESC[0;33mDEFAULT_MANAGED_STR(/Users/jdavid/.ansible.cfg) = Ansible managedESC[0m\r\nESC[0;33mDEFAULT_ROLES_PATH(/Users/jdavid/.ansible.cfg) = ['/Users/jdavid/BAC/ansible/ansible-roles']ESC[0m\r\nESC[0;33mDEFAULT_TIMEOUT(/Users/jdavid/.ansible.cfg) = 30ESC[0m\r\nESC[0;33mINVENTORY_IGNORE_EXTS(/Users/jdavid/.ansible.cfg) = ['~', '.orig', '.bak', '.ini', '.cfg', '.retry', '.pyc', '.pyo']ESC[0m\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\n<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->\r\nSystem Version:\tmacOS 10.13.6 (17G65)\r\n  Kernel Version:\tDarwin 17.7.0\r\n  Boot Volume:\tMacintosh HD\r\n  Boot Mode:\tNormal\r\n  User Name:\tJan David (jdavid)\r\n  Secure Virtual Memory:\tEnabled\r\n  System Integrity Protection:\tEnabled\r\n  Time since boot:\t1 day 18:38\r\n\r\n##### STEPS TO REPRODUCE\r\n<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->\r\nThis can be reproduced anywhere using the simple playbook below. Nothing special is required.\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```yaml\r\n---\r\n- hosts: Test\r\n  gather_facts: no\r\n  become: no\r\n\r\n  tasks:\r\n\r\n  - name: Do something\r\n    command: echo \"Hello World\"\r\n    args:\r\n      removes: /tmp/mytest\r\n    register: result\r\n\r\n  - debug:\r\n      var: result\r\n\r\n  - name: Do something else\r\n    command: echo \"Hello You\"\r\n    when: result is skipped\r\n```\r\n\r\n<!--- HINT: You can paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- Describe what you expected to happen when running the steps above -->\r\nThe first task \"Do something\" should not run, as the file /tmp/mytest does not exist. This works as expected and can be verified in the output of the debug statement of the result variable. The last task however, **should** run because the when statement states that it should perform the task when the first task is skipped.\r\n\r\n##### ACTUAL RESULTS\r\n<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->\r\nThe last task is always skipped. In other words \"result is skipped\" always evaluates to false. I expect this test to evaluate to true, because result was indeed skipped.\r\n\r\n<!--- Paste verbatim command output between quotes -->\r\n```paste below\r\nPLAY [Test] *******************************************************************************************************************************************************************************************************************************\r\n\r\nTASK [Do something] ***********************************************************************************************************************************************************************************************************************\r\nThursday 06 September 2018  10:51:46 +0200 (0:00:00.066)       0:00:00.066 ****\r\nok: [pulp02prod.brusselsairport.aero]\r\n\r\nTASK [debug] ******************************************************************************************************************************************************************************************************************************\r\nThursday 06 September 2018  10:51:47 +0200 (0:00:00.782)       0:00:00.849 ****\r\nok: [pulp02prod.brusselsairport.aero] => {\r\n    \"result\": {\r\n        \"changed\": false,\r\n        \"cmd\": [\r\n            \"echo\",\r\n            \"Hello World\"\r\n        ],\r\n        \"failed\": false,\r\n        \"rc\": 0,\r\n        \"stdout\": \"skipped, since /tmp/mytest does not exist\",\r\n        \"stdout_lines\": [\r\n            \"skipped, since /tmp/mytest does not exist\"\r\n        ]\r\n    }\r\n}\r\n\r\nTASK [Do something else] ******************************************************************************************************************************************************************************************************************\r\nThursday 06 September 2018  10:51:47 +0200 (0:00:00.051)       0:00:00.900 ****\r\nskipping: [pulp02prod.brusselsairport.aero]\r\n\r\nPLAY RECAP ********************************************************************************************************************************************************************************************************************************\r\npulp02prod.brusselsairport.aero : ok=2    changed=0    unreachable=0    failed=0\r\n\r\nThursday 06 September 2018  10:51:47 +0200 (0:00:00.023)       0:00:00.923 ****\r\n===============================================================================\r\nDo something ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.78s\r\ndebug ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 0.05s\r\nDo something else ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 0.02s\r\nPlaybook run took 0 days, 0 hours, 0 minutes, 0 seconds\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/419111718","html_url":"https://github.com/ansible/ansible/issues/45275#issuecomment-419111718","issue_url":"https://api.github.com/repos/ansible/ansible/issues/45275","id":419111718,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTExMTcxOA==","user":{"login":"sivel","id":39340,"node_id":"MDQ6VXNlcjM5MzQw","avatar_url":"https://avatars3.githubusercontent.com/u/39340?v=4","gravatar_id":"","url":"https://api.github.com/users/sivel","html_url":"https://github.com/sivel","followers_url":"https://api.github.com/users/sivel/followers","following_url":"https://api.github.com/users/sivel/following{/other_user}","gists_url":"https://api.github.com/users/sivel/gists{/gist_id}","starred_url":"https://api.github.com/users/sivel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivel/subscriptions","organizations_url":"https://api.github.com/users/sivel/orgs","repos_url":"https://api.github.com/users/sivel/repos","events_url":"https://api.github.com/users/sivel/events{/privacy}","received_events_url":"https://api.github.com/users/sivel/received_events","type":"User","site_admin":false},"created_at":"2018-09-06T14:21:44Z","updated_at":"2018-09-06T14:21:44Z","author_association":"MEMBER","body":"The problem here is that the `command` module with `removed`, does not actually produce a skipped task.\r\n\r\nA skipped task is defined as one that is skipped by the task executor because a condition prevented it from needing to run.\r\n\r\nThe `command` module, must always run, even with `removes` as it has to run on the target host to determine if the file exists or not.  In this case, the valid status for that command is indeed `ok` and not `skipped`.\r\n\r\nThe `stdout` included in the output indicates the reasoning for the `ok` message.\r\n\r\nAs such, the `skipped` test will not match for this task.\r\n\r\nInstead you would need to use:\r\n\r\n```\r\nwhen: '\"skipped\" in result.stdout'\r\n```\r\n\r\nIf you have further questions please stop by IRC or the mailing list:\r\n\r\n   * IRC: #ansible on irc.freenode.net\r\n   * mailing list: https://groups.google.com/forum/#!forum/ansible-project "}}
{"actor":{"display_login":"sivel"}}