On 3/31/20 9:00 PM, Ronen Levinson wrote:
> Hi, 
> 
> I'm using ansible version 2.7.17 and combining multiple playbooks in one file.
> One of my playbooks I'm running conditionally with when and a condition.
> My problem is when my condition is false, I want ansible to completely ignore 
> my playbook and not load anything related
> to this playbook.
> I tried using both import_playbook and include, which seems to have similar 
> results.
> The call to the playbook looks like that:
> 
> - name: Include kubespray tasks
> include: ../kubespray/cluster.yml
> when: cluster_installation
> 
> in my output you can see ansible run the handlers inside the ignored playbook 
> (keeping for 2 more minutes):
> 
> PLAYBOOK: cluster.yml
> *******************************************************************************************************************************************************************************************
> 16 plays in cluster.yml
> 
> PLAY [localhost]
> ************************************************************************************************************************************************************************************************
> META: ran handlers
> Tuesday 31 March 2020 18:55:46 +0000 (0:00:00.043) 0:00:00.043 *********
> META: ran handlers
> META: ran handlers
> [WARNING]: Could not match supplied host pattern, ignoring: bastion
> 
> 
> PLAY [bastion[0]]
> ***********************************************************************************************************************************************************************************************
> skipping: no hosts matched
> 
> PLAY [k8s-cluster:etcd]
> *****************************************************************************************************************************************************************************************
> META: ran handlers
> Tuesday 31 March 2020 18:55:46 +0000 (0:00:00.037) 0:00:00.081 *********
> Tuesday 31 March 2020 18:55:46 +0000 (0:00:00.049) 0:00:00.130 *********
> Tuesday 31 March 2020 18:55:46 +0000 (0:00:00.048) 0:00:00.178 *********
> Tuesday 31 March 2020 18:55:46 +0000 (0:00:00.051) 0:00:00.230 *********
> Tuesday 31 March 2020 18:55:46 +0000 (0:00:00.024) 0:00:00.254 *********
> Tuesday 31 March 2020 18:55:46 +0000 (0:00:00.021) 0:00:00.275 *********
> 
> Thanks for the help,
> Ronen

Hello Ronen,

as far as I know that's not possible. Ansible will parse the role even if the 
condition evalulates to false.
Also note that allows you to use the variables in the role, even if all tasks 
are skipped due to the condition.

Does it really run the handlers? I don't see no output indicating this.

Regards
         Racke

> 
> -- 
> 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
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ce7a36bb-ceab-46ee-ae75-817417cc8fb7%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ce7a36bb-ceab-46ee-ae75-817417cc8fb7%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7d3c030b-857a-e056-a929-c11271bd2292%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to