On Saturday, February 29, 2020 at 11:36:57 PM UTC-6, Vladimir Botka wrote: > > On Sat, 29 Feb 2020 13:13:10 -0800 (PST) > Stephen Gevers <[email protected] <javascript:>> wrote: > > > I opened an issue <https://github.com/ansible/ansible/issues/67410> > > ... I created a playbook where two hosts ... > > > > [...] > > 2. remove the file from host1 using a when option to limit the action > to > > the desired host (output shows "skipping & changed") > > Clarification is needed. Why the membership of "solr" in the list of > groups > "group_names" is tested when "solr" is a host!? > > Quoting from the issue #67410: > > - name: Test shared file issue > hosts: dmgr:solr > ... > tasks: > ... > - name: Remove the file from solr > file: > path: "{{ shared_dir }}/testfile" > state: absent > when: "'solr' in group_names" > > Thank you, > > -vlado >
solr is not a host, it is a group. It just happens to be a group of one host. Likewise, dmgr is a group of one host. Consider the following inventory: [dmgr] host1.example.com [solr] host2.example.com In our application model, dmgr and solr are two functions. On some environments, they run on the same host and on other environments they run on different hosts. I'm using when to limit the tasks to one host or the other. If the two functions happen to run on the same host, the when condition will always match. Where I discovered the problem, the task list was in a role, so creating separate plays with different hosts is not an option. This playbook is just a simplified playbook that exemplifies the problem. The tasks in the play are all executed against the hosts dmgr:solr. -- 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/17ac70cf-0326-4386-bbbb-8456f09307ff%40googlegroups.com.
