From c39d7b14dbb158650e206cb67db6eeb02ea6d2be Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 22 May 2023 10:40:07 -0400 Subject: [PATCH] add task if host match --- test_includes.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test_includes.yml b/test_includes.yml index 53fbe30..bc382fa 100644 --- a/test_includes.yml +++ b/test_includes.yml @@ -11,6 +11,7 @@ # loop_var: install_product vars: + host_match: lab-dev-1 install_products: - inc1 - inc2 @@ -20,10 +21,17 @@ tasks: - - name: Debug upgrade + - name: Debug y0 ansible.builtin.debug: msg: "y0" + + - name: Loop vars if host match + when: host_match in inventory_hostname + ansible.builtin.debug: + msg: "{{ item }}" + loop: "{{ install_products }}" + # - name: Includes on loop # ansible.builtin.include_tasks: "includes/{{ item }}.yml" # loop: "{{ install_products }}"