Disregard this email. Wrong assumption about "group_names". Sorry for the
noise.

        -vlado

On Wed, 4 Mar 2020 05:27:57 +0100
Vladimir Botka <vbo...@gmail.com> wrote:

> On Tue, 3 Mar 2020 19:36:11 -0800 (PST)
> Stephen Gevers <actionphot...@gmail.com> wrote:
> 
> > 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  
> 
> This justifies the developer's conclusion:
> https://github.com/ansible/ansible/issues/67410#issuecomment-590919487
> 
>   "This is a race condition between two different hosts modifying the same
>   shared file, which is asking for trouble. There isn't much we can do in
>   code to fix this."
> 
> And in the same time, this reveals the problem in the code. The condition is
> true for both hosts. (I have no idea why "solr" reports "skipping")
> 
>   - hosts: dmgr:solr
> 
>     ...
> 
>     - name: create the file on dmgr
>       shell: 'echo "Hello World" > {{ shared_dir }}/testfile'
>       when: "'dmgr' in group_names"
> 
>     TASK [create the file on dmgr]
>     *************************************************
>     skipping: [SOLR REDACTED]
>     changed: [DMGR REDACTED]
> 
> Anyway, the solution is to fix the conditions and limit the deletion and
> creation of the file to the host from one group only. For example
> 
>   - name: Remove the file from solr
>     file:
>       path: "{{ shared_dir }}/testfile"
>       state: absent
>     when: inventory_hostname in groups.solr
> 
>    ...
> 
>   - name: create the file on dmgr
>     shell: 'echo "Hello World" > {{ shared_dir }}/testfile'
>     when: inventory_hostname in groups.dmgr
> 
> As a side-note, it's possible to use "copy" instead of "shell"
> 
>   - name: create the file on dmgr
>     copy:
>       content: 'echo "Hello World"'
>       dest: "{{ shared_dir }}/testfile"
>     when: inventory_hostname in groups.dmgr
> 
> HTH,
> 
>       -vlado

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200304065550.095c491c%40gmail.com.

Attachment: pgpwVTNePOhW9.pgp
Description: OpenPGP digital signature

Reply via email to