Ansible 2.5 become directive and include_tasks

68 views
Skip to first unread message

Petr Častulík

unread,
Apr 18, 2018, 6:23:24 AM4/18/18
to Ansible Project
Hello,

I have a question concerning the become directive and include_tasks. After Ansible upgrade to 2.5 the become directive is not escalated to included tasks.

I'm aware of https://docs.ansible.com/ansible/2.5/porting_guides/porting_guide_2.5.html#dynamic-includes-and-attribute-inheritance, especially:

All attributes applied to a dynamic include_* would only apply to the include itself, while attributes applied to a static import_* would be inherited by the tasks within.

Hence my question is whether "attributes" word involves also the become directive(s) or it is a bug?

This new behaviour makes upgrade much harder than expected and become for include_tasks itself doesn't make a sense.

Thank you
Petr

$ ansible --version
ansible 2.5.0
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]

$ cat whoami
-playbook.yml
---
- name: playbook to check escalation of become
  hosts
: localhost
  connection
: local
  tasks
:
   
- name: become include_tasks
      include_tasks
: whoami.yml
      become
: yes


   
- name: become import_tasks
      import_tasks
: whoami.yml
      become
: yes


$ cat whoami
.yml
---
- name: ask whoami
  command
: whoami
 
register: whoami


- debug: var=whoami.stdout


$ ansible
-playbook whoami-playbook.yml


PLAY
[playbook to check propagation of become] ***********************************************************************************************************************************************************************************************


TASK
[Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok
: [localhost]


TASK
[become include_tasks] ******************************************************************************************************************************************************************************************************************
included
: /home/casta/Archive/Projects/sandpit-ansible/whoami.yml for localhost


TASK
[ask whoami] ****************************************************************************************************************************************************************************************************************************
changed
: [localhost]


TASK
[debug] *********************************************************************************************************************************************************************************************************************************
ok
: [localhost] => {
   
"whoami.stdout": "casta"
}


TASK
[ask whoami] ****************************************************************************************************************************************************************************************************************************
changed
: [localhost]


TASK
[debug] *********************************************************************************************************************************************************************************************************************************
ok
: [localhost] => {
   
"whoami.stdout": "root"
}


PLAY RECAP
***********************************************************************************************************************************************************************************************************************************
localhost                  
: ok=6    changed=2    unreachable=0    failed=0  



Matt Martz

unread,
Apr 18, 2018, 10:10:00 AM4/18/18
to ansible...@googlegroups.com
`become` is also an attribute.  This is the expected behavior in 2.5

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/309f9746-d6d3-4fbf-bd18-5fb3ac788464%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Petr Častulík

unread,
Apr 18, 2018, 12:30:24 PM4/18/18
to ansible...@googlegroups.com
Hello Matt, thank you for the confirmation. Best regards, Petr

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
--
Matt Martz
@sivel
sivel.net

--
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-proje...@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/CAD8N0v_-%2BY4PYapymT9dtZd2Tiydx9utd%3DKmnx0vmPSUVfGWzg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages