I have this inventory file
[app:children]
CL
#BA
#EA
#EB
#EI
[BA]
TEST-cl1 ansible_user=ec2-user modulename=BA
[CL]
TEST-cl1 ansible_user=ec2-user modulename=CL
TEST-cl1 ansible_user=ec2-user modulename=CL
TEST-cl1 ansible_user=ec2-user modulename=CL
[EA]
TEST-cl1 ansible_user=ec2-user modulename=EA
[EB]
TEST-cl1 ansible_user=ec2-user modulename=EB
[EI]
TEST-cl1 ansible_user=ec2-user modulename=EI
Assume my playbook is like this:
---
- name: RUNNING DEPLOYMENT TASKS
hosts: app
connection: ssh
gather_facts: no
remote_user: ec2-user
tasks:
- name: print visit particulars
shell: echo {{ modulename }} >> f
What will the file "f" contain?
I would like to see "CL" as all but CL is commented off in that app group. However I see EI which I find quite disappointing (do you get why?)
Since I specify hosts: app in my playbook I thought that the children under app will be selected. Why isn't this so, and how should I code it so that I control where the task is run?
Just test with
debugmodule – Print statements during execution.Right, that's the case.
A minimal example with an inventory file of
example.comand a playbook
modulename.ymlcalled via
will result into an output of
You may have another look under How to build your inventory, especially Inventory basics: formats, hosts, and groups.