Hi,
I’m trying to get some clarity on the expected behaviour of the following scenario. I’ve included the file contents of a demonstration set of roles below. My question is about the behaviour of the include vs import changes between 2.3.2.0 and 2.4+. On 2.3.2.0, the included
role would be executed as part of roles/first/tasks/main.yml. But in 2.4+, the included role is never executed at all, seemingly because the excluded second role (which has a dependency on first) is excluded.
My expectation is the 2.3.2.0 behaviour where as first explicitly included, the included will be executed at that point.
Note: included isn’t specified as a meta dependency of first as it is required to run at a particular point in the execution of first. The second role is skipped for conditional reasons but I don’t want that to affect the inclusion in the first role. It’s a bit unnerving if a role further down the playbook can have an impact on what a previous role in the playbook actually executes. i.e. I could have a playbook that does everything I want, then add a new conditional role to the playbook and break the original functionality.
Is this behaviour correct? Should I be changing the include_role in first to be import_role or doing something different, or is there something not right?
Running on ubuntu 14.04 and 16.04 with python 2.7.11.
Any advice would be greatly appreciated.
Many thanks,
Dave
With ansible 2.3.2.0, the “debug message from included” is executed as expected:
`
PLAY [localhost] *******************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************
ok: [localhost]
TASK [first : first debug from first] **********************************************************************************************************************
ok: [localhost] => {
“msg”: “first debug from first”
}
TASK [included : debug message from included] **************************************************************************************************************
ok: [localhost] => {
“msg”: “debug message from included”
}
TASK [first : last debug from first] ***********************************************************************************************************************
ok: [localhost] => {
“msg”: “last debug from first”
}
TASK [included : debug message from included] **************************************************************************************************************
skipping: [localhost]
TASK [second : Debug from second] **************************************************************************************************************************
skipping: [localhost]
PLAY RECAP *************************************************************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=0
`
With ansible 2.5.0, the “debug message from included” is skipped:
`
PLAY [localhost] *******************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************
ok: [localhost]
TASK [first : first debug from first] **********************************************************************************************************************
ok: [localhost] => {
“msg”: “first debug from first”
}
TASK [first : include_role] ********************************************************************************************************************************
TASK [included : debug message from included] **************************************************************************************************************
skipping: [localhost]
TASK [first : last debug from first] ***********************************************************************************************************************
ok: [localhost] => {
“msg”: “last debug from first”
}
TASK [second : Debug from second] **************************************************************************************************************************
skipping: [localhost]
PLAY RECAP *************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0
`
To run the playbook:
ansible-playbook -i "localhost," -c local playbook.yml
playbook.yml
`