Discussion:
[ansible-project] Setting dynamic 'become' doesn't work #11381
Albert Mikaelyan
2015-07-21 07:09:38 UTC
Permalink
Closed issue 11381 still *not* fixed:
https://github.com/ansible/ansible/issues/11381

The test done by jimi-c <https://github.com/jimi-c> is not related (he was
setting 'become_user', not 'become').

Here is my test, which shows the problem (using latest devel):

$ cat 11381.yml
---
- hosts: antest
gather_facts: no
tasks:
- command: whoami
become: "{{ app_become }}"
become_user: my_user

$ ansible-playbook 11381.yml -vv -e app_become=no

Using /home/albert/ansible/ansible.cfg as config file
1 plays in 11381.yml
PLAY
****************************************************************************
TASK [command]
******************************************************************
"2015-07-21 09:50:31.95193
5", "stderr": "", "stdout": "my_user", "stdout_lines": ["my_user"],
"warnings": []}
PLAY RECAP
**********************************************************************
antest : ok=1 changed=1 unreachable=0
failed=0
*It still sets*
*'become: yes'*However there's this workaround:

$ cat 11381-2.yml
---
- hosts: antest
gather_facts: no
tasks:
- command: whoami
become: "{{ app_become | default('False') | bool }}"
become_user: my_user


$ ansible-playbook 11381.yml -vv -e app_become=false

Using /home/albert/ansible/ansible.cfg as config file
1 plays in 11381.yml
PLAY
****************************************************************************
TASK [command]
******************************************************************
"2015-07-21 09:55:17.90857
[]}
PLAY RECAP
**********************************************************************
antest : ok=1 changed=1 unreachable=0
failed=0
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b7b37211-6cb9-4101-8f88-41fe2654fdbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
James Cammarata
2015-07-21 12:31:10 UTC
Permalink
Hi Albert, the original issue was about an error regarding that value being
set to yes and it failing to work. I did a follow-up test with that and it
worked, however there was no mention of the above in the issue, so I'll
re-open the issue.

James Cammarata
Director, Ansible Core Engineering
github: jimi-c
Post by Albert Mikaelyan
https://github.com/ansible/ansible/issues/11381
The test done by jimi-c <https://github.com/jimi-c> is not related (he
was setting 'become_user', not 'become').
$ cat 11381.yml
---
- hosts: antest
gather_facts: no
- command: whoami
become: "{{ app_become }}"
become_user: my_user
$ ansible-playbook 11381.yml -vv -e app_become=no
Using /home/albert/ansible/ansible.cfg as config file
1 plays in 11381.yml
PLAY
****************************************************************************
TASK [command]
******************************************************************
"2015-07-21 09:50:31.95193
5", "stderr": "", "stdout": "my_user", "stdout_lines": ["my_user"],
"warnings": []}
PLAY RECAP
**********************************************************************
antest : ok=1 changed=1 unreachable=0
failed=0
*It still sets*
$ cat 11381-2.yml
---
- hosts: antest
gather_facts: no
- command: whoami
become: "{{ app_become | default('False') | bool }}"
become_user: my_user
$ ansible-playbook 11381.yml -vv -e app_become=false
Using /home/albert/ansible/ansible.cfg as config file
1 plays in 11381.yml
PLAY
****************************************************************************
TASK [command]
******************************************************************
"2015-07-21 09:55:17.90857
[]}
PLAY RECAP
**********************************************************************
antest : ok=1 changed=1 unreachable=0
failed=0
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b7b37211-6cb9-4101-8f88-41fe2654fdbe%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/b7b37211-6cb9-4101-8f88-41fe2654fdbe%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAMFyvFjMZ98pB%2BD0-pULW67EXFo0OnL1MiSbWtok%2BsRXmYyrZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Albert Mikaelyan
2015-07-21 12:43:58 UTC
Permalink
You are right, 1.9.1 was throwing an error, but devel was showing the
behaviour of always setting it to 'true', as I mentioned on my comment to
Brian Coca (and showed here as well)
Post by James Cammarata
Hi Albert, the original issue was about an error regarding that value
being set to yes and it failing to work. I did a follow-up test with that
and it worked, however there was no mention of the above in the issue, so
I'll re-open the issue.
James Cammarata
Director, Ansible Core Engineering
github: jimi-c
Post by Albert Mikaelyan
https://github.com/ansible/ansible/issues/11381
The test done by jimi-c <https://github.com/jimi-c> is not related (he
was setting 'become_user', not 'become').
$ cat 11381.yml
---
- hosts: antest
gather_facts: no
- command: whoami
become: "{{ app_become }}"
become_user: my_user
$ ansible-playbook 11381.yml -vv -e app_become=no
Using /home/albert/ansible/ansible.cfg as config file
1 plays in 11381.yml
PLAY
****************************************************************************
TASK [command]
******************************************************************
"2015-07-21 09:50:31.95193
5", "stderr": "", "stdout": "my_user", "stdout_lines": ["my_user"],
"warnings": []}
PLAY RECAP
**********************************************************************
antest : ok=1 changed=1 unreachable=0
failed=0
*It still sets*
$ cat 11381-2.yml
---
- hosts: antest
gather_facts: no
- command: whoami
become: "{{ app_become | default('False') | bool }}"
become_user: my_user
$ ansible-playbook 11381.yml -vv -e app_become=false
Using /home/albert/ansible/ansible.cfg as config file
1 plays in 11381.yml
PLAY
****************************************************************************
TASK [command]
******************************************************************
"2015-07-21 09:55:17.90857
4", "stderr": "", "stdout": "root", "stdout_lines": ["root"],
"warnings": []}
PLAY RECAP
**********************************************************************
antest : ok=1 changed=1 unreachable=0
failed=0
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b7b37211-6cb9-4101-8f88-41fe2654fdbe%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/b7b37211-6cb9-4101-8f88-41fe2654fdbe%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b79bd67e-c77f-4f99-af0e-6b63513243c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...