Skip import playbook using when condition.

11 views
Skip to first unread message

Pandu jh

unread,
Feb 27, 2019, 1:43:29 PM2/27/19
to Ansible Project

If there are no hosts added to add host, subsequent plays should be skipped. Please let me know how to provide when condition for this

- name:
hosts: rchadm01
vars_files:
- var.yml
tasks:
- name:
add_host:
name: "{{ decom_host }}"
groups: decom_host_group

- import_playbook: sub_plays/play2.yml
when: '"decom_host_group" not in group_names'

James Cassell

unread,
Feb 27, 2019, 2:07:21 PM2/27/19
to Ansible List
On Wed, Feb 27, 2019, at 1:43 PM, Pandu jh wrote:
>
> If there are no hosts added to add host, subsequent plays should be
> skipped. Please let me know how to provide when condition for this
>

with import_*, the import happens unconditionally and the specified conditions on the import are applied to each task imported.

V/r,
James Cassell

Pandu jh

unread,
Feb 28, 2019, 7:45:01 AM2/28/19
to Ansible Project
Ok, Thank you James
Reply all
Reply to author
Forward
0 new messages