{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/16937","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/16937/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/16937/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/16937/events","html_url":"https://github.com/ansible/ansible/issues/16937","id":169161324,"number":16937,"title":"Blocks: rescue or always not run when error comes from a run_once task","user":{"login":"Gugli","id":2990145,"avatar_url":"https://avatars.githubusercontent.com/u/2990145?v=3","gravatar_id":"","url":"https://api.github.com/users/Gugli","html_url":"https://github.com/Gugli","followers_url":"https://api.github.com/users/Gugli/followers","following_url":"https://api.github.com/users/Gugli/following{/other_user}","gists_url":"https://api.github.com/users/Gugli/gists{/gist_id}","starred_url":"https://api.github.com/users/Gugli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gugli/subscriptions","organizations_url":"https://api.github.com/users/Gugli/orgs","repos_url":"https://api.github.com/users/Gugli/repos","events_url":"https://api.github.com/users/Gugli/events{/privacy}","received_events_url":"https://api.github.com/users/Gugli/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"jimi-c","id":26403,"avatar_url":"https://avatars.githubusercontent.com/u/26403?v=3","gravatar_id":"","url":"https://api.github.com/users/jimi-c","html_url":"https://github.com/jimi-c","followers_url":"https://api.github.com/users/jimi-c/followers","following_url":"https://api.github.com/users/jimi-c/following{/other_user}","gists_url":"https://api.github.com/users/jimi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/jimi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimi-c/subscriptions","organizations_url":"https://api.github.com/users/jimi-c/orgs","repos_url":"https://api.github.com/users/jimi-c/repos","events_url":"https://api.github.com/users/jimi-c/events{/privacy}","received_events_url":"https://api.github.com/users/jimi-c/received_events","type":"User","site_admin":false},"assignees":[{"login":"jimi-c","id":26403,"avatar_url":"https://avatars.githubusercontent.com/u/26403?v=3","gravatar_id":"","url":"https://api.github.com/users/jimi-c","html_url":"https://github.com/jimi-c","followers_url":"https://api.github.com/users/jimi-c/followers","following_url":"https://api.github.com/users/jimi-c/following{/other_user}","gists_url":"https://api.github.com/users/jimi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/jimi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimi-c/subscriptions","organizations_url":"https://api.github.com/users/jimi-c/orgs","repos_url":"https://api.github.com/users/jimi-c/repos","events_url":"https://api.github.com/users/jimi-c/events{/privacy}","received_events_url":"https://api.github.com/users/jimi-c/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/ansible/ansible/milestones/6","html_url":"https://github.com/ansible/ansible/milestones/stable-2.1","labels_url":"https://api.github.com/repos/ansible/ansible/milestones/6/labels","id":995714,"number":6,"title":"stable-2.1","description":"","creator":{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"open_issues":31,"closed_issues":241,"state":"open","created_at":"2015-02-25T19:26:53Z","updated_at":"2016-08-11T19:34:50Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2016-08-03T15:29:48Z","updated_at":"2016-08-12T17:21:42Z","closed_at":null,"body":"##### ISSUE TYPE\r\n - Bug Report\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\nOut of the box config on Ubuntu14\r\n\r\n##### OS / ENVIRONMENT\r\nAnsible runs on Ubuntu14, targeted machines on Ubuntu16.\r\n\r\n##### SUMMARY\r\nUsing `run_once` on a task inside a block prevents `rescue` and `always` sections to be correctly triggered.\r\n\r\n##### STEPS TO REPRODUCE\r\nRun this playbook on any inventory file. This is basically the sample from [the official documentation](http://docs.ansible.com/ansible/playbooks_blocks.html#block-error-handling-example) with just a `run_once` added\r\n\r\n```\r\n# Contents of bug_blocks.yml\r\n- hosts: all\r\n  gather_facts: false\r\n  tasks:\r\n  - block:\r\n      - debug: msg='I execute normally'\r\n      - command: /bin/false\r\n        run_once: true\r\n      - debug: msg='I never execute, cause ERROR!'\r\n    rescue:\r\n      - debug: msg='I caught an error'\r\n      - command: /bin/false\r\n      - debug: msg='I also never execute :-('\r\n    always:\r\n      - debug: msg=\"this always executes\"\r\n```\r\n\r\n\r\n##### EXPECTED RESULTS\r\nI was expecting \r\n```\r\n$ ansible-playbook bug_blocks.yml --inventory-file inventories/\r\n\r\nPLAY [all] *********************************************************************\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"i execute normally\"\r\n}\r\n\r\nTASK [command] *****************************************************************\r\nfatal: [localhost]: FAILED! => {\"changed\": true, \"cmd\": [\"/bin/false\"], \"delta\": \"0:00:00.002056\", \"end\": \"2016-08-03 17:04:07.156094\", \"failed\": true, \"rc\": 1, \"start\": \"2016-08-03 17:04:07.154038\", \"stderr\": \"\", \"stdout\": \"\", \"stdout_lines\": [], \"warnings\": []}\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"I caught an error\"\r\n}\r\n\r\nTASK [command] *****************************************************************\r\nfatal: [localhost]: FAILED! => {\"changed\": true, \"cmd\": [\"/bin/false\"], \"delta\": \"0:00:00.001853\", \"end\": \"2016-08-03 17:04:07.988953\", \"failed\": true, \"rc\": 1, \"start\": \"2016-08-03 17:04:07.987100\", \"stderr\": \"\", \"stdout\": \"\", \"stdout_lines\": [], \"warnings\": []}\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"this always executes\"\r\n}\r\n\r\nNO MORE HOSTS LEFT *************************************************************\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=2    changed=0    unreachable=0    failed=1\r\nTASK: command ----------------------------------------------------------- 0.79s\r\nTASK: command ----------------------------------------------------------- 0.40s\r\nTASK: debug ------------------------------------------------------------- 0.11s\r\nTASK: debug ------------------------------------------------------------- 0.09s\r\nTASK: debug ------------------------------------------------------------- 0.07s\r\n\r\nPlaybook finished: Wed Aug  3 17:04:08 2016, 5 total tasks.  0:00:01 elapsed.\r\n```\r\n\r\n##### ACTUAL RESULTS\r\n```\r\n$ ansible-playbook bug_blocks.yml --inventory-file inventories/\r\n\r\nPLAY [all] *********************************************************************\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": \"i execute normally\"\r\n}\r\n\r\nTASK [command] *****************************************************************\r\nfatal: [localhost]: FAILED! => {\"changed\": true, \"cmd\": [\"/bin/false\"], \"delta\": \"0:00:00.001284\", \"end\": \"2016-08-03 17:03:52.951110\", \"failed\": true, \"rc\": 1, \"start\": \"2016-08-03 17:03:52.949826\", \"stderr\": \"\", \"stdout\": \"\", \"stdout_lines\": [], \"warnings\": []}\r\n\r\nNO MORE HOSTS LEFT *************************************************************\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=1    changed=0    unreachable=0    failed=0\r\n\r\nTASK: command ----------------------------------------------------------- 0.71s\r\nTASK: debug ------------------------------------------------------------- 0.09s\r\n\r\nPlaybook finished: Wed Aug  3 17:26:37 2016, 2 total tasks.  0:00:00 elapsed.\r\n```\r\n\r\n##### Related issues\r\nThis might be related to #16254, but the steps to reproduce are so different I though it best to make a new Issue report.\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/239506982","html_url":"https://github.com/ansible/ansible/issues/16937#issuecomment-239506982","issue_url":"https://api.github.com/repos/ansible/ansible/issues/16937","id":239506982,"user":{"login":"jimi-c","id":26403,"avatar_url":"https://avatars.githubusercontent.com/u/26403?v=3","gravatar_id":"","url":"https://api.github.com/users/jimi-c","html_url":"https://github.com/jimi-c","followers_url":"https://api.github.com/users/jimi-c/followers","following_url":"https://api.github.com/users/jimi-c/following{/other_user}","gists_url":"https://api.github.com/users/jimi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/jimi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimi-c/subscriptions","organizations_url":"https://api.github.com/users/jimi-c/orgs","repos_url":"https://api.github.com/users/jimi-c/repos","events_url":"https://api.github.com/users/jimi-c/events{/privacy}","received_events_url":"https://api.github.com/users/jimi-c/received_events","type":"User","site_admin":false},"created_at":"2016-08-12T17:21:42Z","updated_at":"2016-08-12T17:21:42Z","body":"The branch above is working and passing tests, if anyone else would like to give it a test before I merge it into devel."}}
{"actor":{"display_login":"jimi-c"}}