Hello Team,

is there any way to pass wildcard group in ansible when condition or in j2??

because if try with  *kafka_qa_*_b as a group in j2 because i want to use 
this in j2.*


*if kafka_qa  or any group has zookeeper host then add zookeeper lines else 
add broker lines.*
*it should be common across. *


On Friday, April 19, 2024 at 8:37:51 PM UTC+5:30 Todd Lewis wrote:

> Oops. That second "children:" under "kafka:" shouldn't be there. 
> Otherwise, it's pretty close.
>
> On Friday, April 19, 2024 at 10:58:32 AM UTC-4 Todd Lewis wrote:
>
>> It appears you are trying to define two different "*broker*" groups: one 
>> as a child of the "*dev_kafka_cluster*" and another as a child of "
>> *qa_kafka_cluster*".
>>
>> That isn't how groups work. There is only one "*broker*" group. You have 
>> added hosts to the "*broker*" group in two places.
>>
>> (Also, "*App*" as a group name should be lower-case letters.)
>>
>> Let me suggest an alternative inventory/group arrangement that implements 
>> this naming scheme:
>>
>> *kafka[_{$env}[_{app,web,db}[_{zoo,broker,schema}]]] *In this scheme, 
>> there isn't a "*broker*" group. Instead there are groups named "
>> *kafka_dev_app_broker*" and "*kafka_qa_app_broker*" (and eventually a "
>> *kafka_prd**" set I imagine).
>>
>> I call this type of group naming scheme "fully articulated" — any group 
>> you care to specify is completely unambiguous. It's a set of strict 
>> hierarchies (in this case there's only one hierarchy: "*kafka*"), and 
>> hosts appear in a particular hierarchy exactly once. (If you find yourself 
>> trying to inject a host in two different places, you either need to rethink 
>> your hierarchy's structure, or maybe you need two hierarchies.)
>>
>> We have on occasion included an "*all*" environment (like "*dev*" and "
>> *qa*"). If you did that, there would be a corresponding "*kafka_all**" 
>> group for any "*kafka_dev**" or "*kafka_qa**" groups. Then you could 
>> target all the brokers with "*kafka_all_app_broker*" instead of "
>> *kafka_dev_app_broker**,**kafka_qa_app_broker*". You would have to 
>> decide if the benefit is worth the extra text you have to maintain in your 
>> inventory.
>>
>> Your inventory would look like this:
>>
>> kafka:
>>   children:
>>     kafka_dev:
>>       children:
>>         kafka_dev_app:
>>           children:
>>             kafka_dev_app_zoo:
>>               hosts:
>>                 dev1-main-zookpr[01:05].dev
>>             kafka_dev_app_broker:
>>               hosts:
>>                 dev1-main-kafka[01:06].dev
>>             kafka_dev_app_schema:
>>               hosts:
>>                 dev1-main-kafka[01:06].dev
>>         kafka_dev_web: […] # omitted for brevity,
>>         kafka_dev_db: […]  # but you get the idea.
>>   children:
>>     kafka_qa:
>>       children:
>>         kafka_qa_app:
>>           children:
>>             kafka_qa_app_zoo:
>>               hosts:
>>                 qa1-main-zookpr[01:03].qa
>>             kafka_qa_app_broker:
>>               hosts:
>>                 qa1-main-kafka[01:06].qa
>>             kafka_qa_app_schema:
>>               hosts:
>>                 qa1-main-kafka[04:06].qa
>>         kafka_qa_web: […] # omitted for brevity,
>>         kafka_qa_db: […]  # but you get the idea.
>>
>>
>> On 4/19/24 8:40 AM, Sameer Modak wrote:
>>
>> I have an inventory something like this , each main cluster has children 
>> like broker. 
>> Now how do i run any tasks against perticular group.broker. When we pass 
>> the group with --limit it does not work it runs on all broker.  Also  main 
>> playbook has hosts:all in it
>>
>> annsible/grafana-agent-play.yaml -i kafka_inventory.yaml --limit 
>> qa_kafka_cluster -u sam -k -b 
>>
>> dev_kafka:
>>
>>       children:
>>
>>         App:
>>
>>           children:
>>
>>             dev_kafka_cluster:
>>
>>                children:
>>
>>                  zookeeper:
>>
>>                    hosts: 
>>
>>                      dev1-main-zookpr[01:05].dev
>>
>>                  broker:
>>
>>                    hosts:
>>
>>                      dev1-main-kafka[01:06].dev
>>
>>                  schema_registry:
>>
>>                    hosts:
>>
>>                      dev1-main-kafka[01:06].dev
>>
>>         uc:
>>
>>           children:
>>
>>
>>     qa_kafka:
>>
>>       children:
>>
>>         App:
>>
>>           children:
>>
>>             qa_kafka_cluster:
>>
>>                children:
>>
>>                  zookeeper:
>>
>>                    hosts: 
>>
>>                      qa1-main-zookpr[01:03].qa
>>
>>                  broker:
>>
>>                    hosts:
>>
>>                      qa1-main-kafka[01:06].qa
>>
>>                  schema_registry:
>>
>>                    hosts:
>>
>>                      qa1-main-kafka[04:06].qa
>>
>>
>>
>> ========
>>
>>
>>
>> -- 
>> 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/0e0e0032-661b-4d2e-9fe4-347c08157d7bn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/0e0e0032-661b-4d2e-9fe4-347c08157d7bn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> -- 
>> Todd
>>
>>

-- 
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/01557294-b1c0-42e4-a38c-02ace316663dn%40googlegroups.com.

Reply via email to