Re: [ansible-project] how to run play for subgroup when children has same name

2024-04-25 Thread Todd Lewis
Brian said what to do, but left /how to do it/ as a (very worthwhile) exercise for the reader. It could look something like when: group_names | select('search', '_broker' ) | length > 0 # matches all the broker groups when: group_names | select('search', kenv ~ '_app_zoo') | length >

Re: [ansible-project] Unusal behaviour with set_fact and add_host

2024-04-25 Thread Todd Lewis
I've been staring at this for quite a while. I was able to reproduce your issue, and I now understand what's going on. Rather than trying to duplicate the "single vs. multiple ips on an interface", I just ran a playbook against two hosts (tango and cloister), and did - name: Set

Re: [ansible-project] how to run play for subgroup when children has same name

2024-04-25 Thread Brian Coca
See `select` (or `reject`) filter with `match` test, you can use it to go over group_names. -- -- Brian Coca (he/him/yo) -- 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

Re: [ansible-project] Unusal behaviour with set_fact and add_host

2024-04-25 Thread 'deewon' via Ansible Project
Thanks Todd. My messages kept getting deleted so I thought to try again I probably over-redacted the output of the playbook to only show the relevant bits. The full playbook is below: == playbook == - name: Get Server Recycling Order hosts: "{{ my_servers | default ('localhost') }}"

Re: [ansible-project] Unusal behaviour with set_fact and add_host

2024-04-25 Thread 'deewon' via Ansible Project
Thanks Todd. My messages kept getting deleted so I thought to try again I probably over-redacted the output of the playbook to only show the relevant bits. The full playbook is below: == playbook == - name: Get Server Recycling Order hosts: "{{ my_servers | default ('localhost') }}"

Re: [ansible-project] Unusal behaviour with set_fact and add_host

2024-04-25 Thread 'deewon' via Ansible Project
Thanks Todd. My messages kept getting deleted so I thought to try again I probably over-redacted the output of the playbook to only show the relevant bits. The full playbook is below: == playbook == - name: Get Server Recycling Order hosts: "{{ my_servers | default ('localhost') }}"

Re: [ansible-project] Getting hostnames from a fact

2024-04-25 Thread lift...@gmail.com
I used the stat module as suggested by Todd and it worked perfectly. I appreciate the suggestion and for setting me straight. Thanks, Harry On Thursday, April 25, 2024 at 4:09:28 AM UTC-4 Stuart Lowe wrote: > Something like this should work? > > --- > > - hosts: my_hosts > > become: true >

Re: [ansible-project] Unusal behaviour with set_fact and add_host

2024-04-25 Thread 'deewon' via Ansible Project
Testing if my email is still deleted without any code On Tuesday, April 23, 2024 at 11:28:59 PM UTC+1 Todd Lewis wrote: > All that said, I don't see why this one task wouldn't work for your > purposes: > > - name: Add hosts to groups > ansible.builtin.add_host: > name: "{{

Re: [ansible-project] Ansible hangs on gathering facts

2024-04-25 Thread Dick Visser
I would terminate the host and spin up a fresh one. This means your host will be in a known clean state again. On Thu, 25 Apr 2024 at 12:45, Sven Feyerabend wrote: > > Hi everyone, > > I have a host where Ansible used to run correctly. > A while ago, all runs of Ansible on this host started to

[ansible-project] Ansible hangs on gathering facts

2024-04-25 Thread Sven Feyerabend
Hi everyone, I have a host where Ansible used to run correctly. A while ago, all runs of Ansible on this host started to hang on Gathering Facts. I've searched on the internet for a solution, and found some tips on how to debug this. So I ran Ansible with ANSIBLE_KEEP_REMOTE_FILES=1 and used

Re: [ansible-project] how to run play for subgroup when children has same name

2024-04-25 Thread Sameer Modak
First of all thanks for solution. I tried this but how do we pass wildcard as group *kafka_qa* in when condition or in j2* 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. > >

Re: [ansible-project] how to run play for subgroup when children has same name

2024-04-25 Thread Sameer Modak
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

Re: [ansible-project] Unusal behaviour with set_fact and add_host

2024-04-25 Thread 'deewon' via Ansible Project
Hi Todd. I believe I responded to you but it seems my response was deleted. I can post the full playbook and output if required. A lot of those debug steps were just to understand why the condition was being ignored when "is_leader" is set to false I'll incorporate the suggestion above to

Re: [ansible-project] how to run play for subgroup when children has same name

2024-04-25 Thread Sameer Modak
That was useful. But i still did not quite get how do we pass *kafka_dev* in j2 or during runtime like we dont know before hand what group we will be running against.* *so in when condition can we pass something like this when group is * *kafka_dev** On Friday, April 19, 2024 at 8:37:51 PM

Re: [ansible-project] Unusal behaviour with set_fact and add_host

2024-04-25 Thread 'deewon' via Ansible Project
Thanks for taking a look at this Todd. Apologies for the messy output. I over-redacted in an attempt to post only the relevant information This is the full playbook followed by the output: == playbook == - name: Get Server Recycling Order hosts: "{{ my_servers | default ('localhost') }}"

RE: [ansible-project] Getting hostnames from a fact

2024-04-25 Thread Stuart Lowe
Something like this should work? --- - hosts: my_hosts become: true become_method: sudo gather_facts: false tasks: - name: Determine if /var/log/messages is zero-length ansible.builtin.find: paths: /var/log patterns: messages register: messages_files - name: