{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4077","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4077/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4077/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4077/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/4077","id":163090609,"number":4077,"title":"service module used in handler doesn't get excalated privilege","user":{"login":"asmodehn","id":221256,"avatar_url":"https://avatars.githubusercontent.com/u/221256?v=3","gravatar_id":"","url":"https://api.github.com/users/asmodehn","html_url":"https://github.com/asmodehn","followers_url":"https://api.github.com/users/asmodehn/followers","following_url":"https://api.github.com/users/asmodehn/following{/other_user}","gists_url":"https://api.github.com/users/asmodehn/gists{/gist_id}","starred_url":"https://api.github.com/users/asmodehn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmodehn/subscriptions","organizations_url":"https://api.github.com/users/asmodehn/orgs","repos_url":"https://api.github.com/users/asmodehn/repos","events_url":"https://api.github.com/users/asmodehn/events{/privacy}","received_events_url":"https://api.github.com/users/asmodehn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/affects_2.1","name":"affects_2.1","color":"5319e7"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/P2","name":"P2","color":"fad8c7"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/waiting_on_maintainer","name":"waiting_on_maintainer","color":"d93f0b"}],"state":"closed","locked":false,"assignee":{"login":"jctanner","id":1869705,"avatar_url":"https://avatars.githubusercontent.com/u/1869705?v=3","gravatar_id":"","url":"https://api.github.com/users/jctanner","html_url":"https://github.com/jctanner","followers_url":"https://api.github.com/users/jctanner/followers","following_url":"https://api.github.com/users/jctanner/following{/other_user}","gists_url":"https://api.github.com/users/jctanner/gists{/gist_id}","starred_url":"https://api.github.com/users/jctanner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jctanner/subscriptions","organizations_url":"https://api.github.com/users/jctanner/orgs","repos_url":"https://api.github.com/users/jctanner/repos","events_url":"https://api.github.com/users/jctanner/events{/privacy}","received_events_url":"https://api.github.com/users/jctanner/received_events","type":"User","site_admin":false},"assignees":[{"login":"jctanner","id":1869705,"avatar_url":"https://avatars.githubusercontent.com/u/1869705?v=3","gravatar_id":"","url":"https://api.github.com/users/jctanner","html_url":"https://github.com/jctanner","followers_url":"https://api.github.com/users/jctanner/followers","following_url":"https://api.github.com/users/jctanner/following{/other_user}","gists_url":"https://api.github.com/users/jctanner/gists{/gist_id}","starred_url":"https://api.github.com/users/jctanner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jctanner/subscriptions","organizations_url":"https://api.github.com/users/jctanner/orgs","repos_url":"https://api.github.com/users/jctanner/repos","events_url":"https://api.github.com/users/jctanner/events{/privacy}","received_events_url":"https://api.github.com/users/jctanner/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/milestones/1","html_url":"https://github.com/ansible/ansible-modules-core/milestones/stable-2.1","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/milestones/1/labels","id":996115,"number":1,"title":"stable-2.1","description":"","creator":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":124,"state":"open","created_at":"2015-02-26T01:01:13Z","updated_at":"2016-09-13T16:11:10Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-06-30T06:29:51Z","updated_at":"2016-09-13T16:11:10Z","closed_at":"2016-09-13T16:11:10Z","body":"Similar to https://github.com/ansible/ansible-modules-core/issues/3018 but a tiny bit different...\r\n\r\n##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\nservice module\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible --version\r\nansible 2.1.0.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 on ubuntu trusty package Version: 2.1.0.0-1ppa~trusty\r\n\r\n##### OS / ENVIRONMENT\r\nUbuntu Trusty\r\n\r\n##### SUMMARY\r\nI am using [supervisor](https://galaxy.ansible.com/tersmitten/supervisor) role as a dependency to ensure all services are restarted after reconfiguration.\r\nI am specifying `become:yes` when using that role. but it seems the handler is not getting that escalated privilege\r\n\r\n##### STEPS TO REPRODUCE\r\n\r\nI am using supervisor as a dependency like so : \r\n```\r\n---\r\n# myrole/meta/main.yml\r\ngalaxy_info:\r\n...\r\ndependencies:\r\n - role: tersmitten.supervisor\r\n   supervisor_programs_present:\r\n     syncthing:\r\n       user: yujin\r\n       environment: STNORESTART=\"1\", HOME=\"/home/some_user\"\r\n       command: /usr/bin/syncthing -no-browser -home=\"/home/yujin/.config/syncthing\r\n       autostart: true\r\n       stdout_logfile: /var/log/supervisor/syncthing.out.log\r\n       stderr_logfile: /var/log/supervisor/syncthing.err.log\r\n```\r\n\r\nThe playbook containing : \r\n```\r\n   - role: myrole\r\n     tags: myrole\r\n     become: yes\r\n```\r\nThe handler in [supervisor](https://galaxy.ansible.com/tersmitten/supervisor) role looks like : \r\n```\r\n# handlers file for supervisor\r\n---\r\n- name: restart supervisor\r\n  service:\r\n    name: supervisor\r\n    state: restarted\r\n  when: supervisor_state == 'started'\r\n```\r\n##### EXPECTED RESULTS\r\nI would expect the handler somehow to be aware that it needs to become (root) and supervisor service to be restarted.\r\n\r\n##### ACTUAL RESULTS\r\n\r\n```\r\nTASK [tersmitten.supervisor : start and enable service] ************************\r\nok: [gocart-server] => {\"changed\": false, \"enabled\": true, \"name\": \"supervisor\", \"state\": \"started\"}\r\n\r\nRUNNING HANDLER [tersmitten.supervisor : restart supervisor] *******************\r\nfatal: [gocart-server]: FAILED! => {\"changed\": false, \"failed\": true, \"msg\": \"start-stop-daemon: warning: failed to kill 20874: Operation not permitted\\n\"}\r\n```\r\n\r\nWe can reproduce this behavior with a privilege issue like so :\r\n```\r\nalexv@asmodehn:~/Projects/yujin_tools/ansible/namsung$ ansible -i devel gocart-server -K -u yujin -m service -a \"name=supervisor state=restarted\" -b\r\nSUDO password: \r\ngocart-server | FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"msg\": \"Stopping supervisor: supervisord.\\nStarting supervisor: \"\r\n}\r\nalexv@asmodehn:~/Projects/yujin_tools/ansible/namsung$ ansible -i devel gocart-server -K -u yujin -m service -a \"name=supervisor state=restarted\" -b\r\nSUDO password: \r\ngocart-server | SUCCESS => {\r\n    \"changed\": true, \r\n    \"name\": \"supervisor\", \r\n    \"state\": \"started\"\r\n}\r\nalexv@asmodehn:~/Projects/yujin_tools/ansible/namsung$ ansible -i devel gocart-server -K -u yujin -m service -a \"name=supervisor state=restarted\"\r\nSUDO password: \r\ngocart-server | FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"msg\": \"start-stop-daemon: warning: failed to kill 786: Operation not permitted\\n\"\r\n}\r\n```"}}
{"actor":{"display_login":"jctanner"}}