{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/17588","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/17588/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/17588/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/17588/events","html_url":"https://github.com/ansible/ansible/issues/17588","id":177205958,"number":17588,"title":"stat.exist not work in when statement","user":{"login":"ARogovsky","id":6280830,"avatar_url":"https://avatars.githubusercontent.com/u/6280830?v=3","gravatar_id":"","url":"https://api.github.com/users/ARogovsky","html_url":"https://github.com/ARogovsky","followers_url":"https://api.github.com/users/ARogovsky/followers","following_url":"https://api.github.com/users/ARogovsky/following{/other_user}","gists_url":"https://api.github.com/users/ARogovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ARogovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARogovsky/subscriptions","organizations_url":"https://api.github.com/users/ARogovsky/orgs","repos_url":"https://api.github.com/users/ARogovsky/repos","events_url":"https://api.github.com/users/ARogovsky/events{/privacy}","received_events_url":"https://api.github.com/users/ARogovsky/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-15T15:17:57Z","updated_at":"2016-09-15T15:23:22Z","closed_at":"2016-09-15T15:23:21Z","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\nstat\r\nwhen\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.1.1.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\nDefault\r\n\r\n##### OS / ENVIRONMENT\r\nDescription:    Ubuntu 16.04 LTS\r\n\r\n##### SUMMARY\r\nModule state is not work in when statement\r\n\r\n##### STEPS TO REPRODUCE\r\nThere is sample yml file is not work:\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\n---\r\n- hosts: localhost\r\n  tasks:\r\n    - stat: path=/etc/foo.conf\r\n      register: st\r\n    - fail: msg=\"File not found\"\r\n      when: st.stat.exist\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nI expect File not found message.\r\n\r\n##### ACTUAL RESULTS\r\nLooks, like stat not work in when statement, couse it throw this error:\r\n\r\n\"The conditional check 'st.stat.exist' failed. The error was: error while evaluating conditional (st.stat.exist): 'dict object' has no attribute 'exist'\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\n# ansible-playbook -vvvvv x.yml \r\nUsing /etc/ansible/ansible.cfg as config file\r\nLoaded callback default of type stdout, v2.0\r\n\r\nPLAYBOOK: x.yml ****************************************************************\r\n1 plays in x.yml\r\n\r\nPLAY [localhost] ***************************************************************\r\n\r\nTASK [setup] *******************************************************************\r\n<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root\r\n<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1473952520.08-219063427451269 `\" && echo ansible-tmp-1473952520.08-219063427451269=\"` echo $HOME/.ansible/tmp/ansible-tmp-1473952520.08-219063427451269 `\" ) && sleep 0'\r\n<127.0.0.1> PUT /tmp/tmpjO_UZS TO /root/.ansible/tmp/ansible-tmp-1473952520.08-219063427451269/setup\r\n<127.0.0.1> EXEC /bin/sh -c 'LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1473952520.08-219063427451269/setup; rm -rf \"/root/.ansible/tmp/ansible-tmp-1473952520.08-219063427451269/\" > /dev/null 2>&1 && sleep 0'\r\nok: [localhost]\r\n\r\nTASK [stat] ********************************************************************\r\ntask path: /root/new/freeipa-ds389d/tests/x.yml:4\r\n<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root\r\n<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1473952520.89-124829052999301 `\" && echo ansible-tmp-1473952520.89-124829052999301=\"` echo $HOME/.ansible/tmp/ansible-tmp-1473952520.89-124829052999301 `\" ) && sleep 0'\r\n<127.0.0.1> PUT /tmp/tmpmzuP3h TO /root/.ansible/tmp/ansible-tmp-1473952520.89-124829052999301/stat\r\n<127.0.0.1> EXEC /bin/sh -c 'LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1473952520.89-124829052999301/stat; rm -rf \"/root/.ansible/tmp/ansible-tmp-1473952520.89-124829052999301/\" > /dev/null 2>&1 && sleep 0'\r\nok: [localhost] => {\"changed\": false, \"invocation\": {\"module_args\": {\"checksum_algorithm\": \"sha1\", \"follow\": false, \"get_checksum\": true, \"get_md5\": true, \"mime\": false, \"path\": \"/etc/foo.conf\"}, \"module_name\": \"stat\"}, \"stat\": {\"exists\": false}}\r\n\r\nTASK [fail] ********************************************************************\r\ntask path: /root/new/freeipa-ds389d/tests/x.yml:6\r\nfatal: [localhost]: FAILED! => {\"failed\": true, \"msg\": \"The conditional check 'st.stat.exist' failed. The error was: error while evaluating conditional (st.stat.exist): 'dict object' has no attribute 'exist'\\n\\nThe error appears to have been in '/root/new/freeipa-ds389d/tests/x.yml': line 6, column 7, but may\\nbe elsewhere in the file depending on the exact syntax problem.\\n\\nThe offending line appears to be:\\n\\n      register: st\\n    - fail: msg=\\\"File not found\\\"\\n      ^ here\\n\"}\r\n\r\nNO MORE HOSTS LEFT *************************************************************\r\n [WARNING]: Could not create retry file 'x.retry'.         [Errno 2] No such file or directory: ''\r\n\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=2    changed=0    unreachable=0    failed=1   \r\n\r\n```\r\n"}}
{"actor":{"display_login":"bcoca"}}