{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/10528","labels_url":"https://api.github.com/repos/ansible/ansible/issues/10528/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/10528/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/10528/events","html_url":"https://github.com/ansible/ansible/issues/10528","id":64048709,"number":10528,"title":"add support for sudo to be templated","user":{"login":"Yannig","id":277760,"avatar_url":"https://avatars.githubusercontent.com/u/277760?v=3","gravatar_id":"","url":"https://api.github.com/users/Yannig","html_url":"https://github.com/Yannig","followers_url":"https://api.github.com/users/Yannig/followers","following_url":"https://api.github.com/users/Yannig/following{/other_user}","gists_url":"https://api.github.com/users/Yannig/gists{/gist_id}","starred_url":"https://api.github.com/users/Yannig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yannig/subscriptions","organizations_url":"https://api.github.com/users/Yannig/orgs","repos_url":"https://api.github.com/users/Yannig/repos","events_url":"https://api.github.com/users/Yannig/events{/privacy}","received_events_url":"https://api.github.com/users/Yannig/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_idea","name":"feature_idea","color":"006b75"},{"url":"https://api.github.com/repos/ansible/ansible/labels/P3","name":"P3","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-03-24T17:05:39Z","updated_at":"2015-07-01T15:57:36Z","closed_at":"2015-07-01T15:57:36Z","body":"I don't know if this issue is related to #10317 bug but here is my problem :\r\n\r\nIf I try to use a boolean condition on the sudo field, ansible does not take care of it. Step to reproduce, launch the following playbook :\r\n\r\n```yaml\r\n- name: \"Ansible not aware of sudo\"\r\n  hosts: \"localhost\"\r\n  connection: local\r\n  vars:\r\n    condition_true: true\r\n  tasks:\r\n    - name: \"No sudo\"\r\n      command: id\r\n      register: id_no_sudo\r\n    - name: \"Sudo\"\r\n      command: id\r\n      sudo: yes\r\n      register: id_sudo\r\n    - name: \"Sudo cond = true\"\r\n      command: id\r\n      sudo: condition_true\r\n      register: id_sudo_cond\r\n    - debug: var=id_no_sudo.stdout_lines[0]\r\n    - debug: var=id_sudo.stdout_lines[0]\r\n    - debug: var=id_sudo_cond.stdout_lines[0]\r\n    - debug: var=condition_true\r\n```\r\n\r\nResult :\r\n```\r\nyannig@travail ~ $ ansible-playbook test.yml \r\n\r\nPLAY [Ansible not aware of sudo] ********************************************** \r\n\r\nGATHERING FACTS *************************************************************** \r\nok: [localhost]\r\n\r\nTASK: [No sudo] *************************************************************** \r\nchanged: [localhost]\r\n\r\nTASK: [Sudo] ****************************************************************** \r\nchanged: [localhost]\r\n\r\nTASK: [Sudo cond = true] ****************************************************** \r\nchanged: [localhost]\r\n\r\nTASK: [debug var=id_no_sudo.stdout_lines[0]] ********************************** \r\nok: [localhost] => {\r\n    \"id_no_sudo.stdout_lines[0]\": \"uid=1000(yannig) gid=1000(yannig) groups=1000(yannig),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),111(sambashare),112(vboxsf)\"\r\n}\r\n\r\nTASK: [debug var=id_sudo.stdout_lines[0]] ************************************* \r\nok: [localhost] => {\r\n    \"id_sudo.stdout_lines[0]\": \"uid=0(root) gid=0(root) groups=0(root)\"\r\n}\r\n\r\nTASK: [debug var=id_sudo_cond.stdout_lines[0]] ******************************** \r\nok: [localhost] => {\r\n    \"id_sudo_cond.stdout_lines[0]\": \"uid=1000(yannig) gid=1000(yannig) groups=1000(yannig),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),111(sambashare),112(vboxsf)\"\r\n}\r\n\r\nTASK: [debug var=condition_true] ********************************************** \r\nok: [localhost] => {\r\n    \"condition_true\": \"True\"\r\n}\r\n\r\nPLAY RECAP ******************************************************************** \r\nlocalhost                  : ok=8    changed=3    unreachable=0    failed=0   \r\n```\r\n\r\nExpected :\r\n\r\nLaunch id as root the third time and not as my current user.\r\n"}}