Remote lookup with remote(...)

1,016 views
Skip to first unread message

anatoly techtonik

unread,
Mar 4, 2014, 10:03:16 PM3/4/14
to ansible...@googlegroups.com
Is it possible to implement remote lookup plugins?

Something like:

  - name: create .hgrc if necessary
    file
: path={{ hgrc }} owner={{ user }} state=touch
   
when: remote('file_exists', '{{ hgrc }}') == False

Brian Coca

unread,
Mar 4, 2014, 10:10:51 PM3/4/14
to ansible...@googlegroups.com
they are called tasks

Brian Coca

unread,
Mar 4, 2014, 10:11:54 PM3/4/14
to ansible...@googlegroups.com
- name: check exists
   stat: path={{hgrc}}
   ignore_errors: true
   register: hgrcfile

 - name: create .hgrc if necessary
   file: path={{ hgrc }} owner={{ user }} state=touch
   when: hgrcfile.failed


On Tue, Mar 4, 2014 at 10:10 PM, Brian Coca <bria...@gmail.com> wrote:
they are called tasks



--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

anatoly techtonik

unread,
Mar 5, 2014, 5:37:23 AM3/5/14
to ansible...@googlegroups.com
On Wed, Mar 5, 2014 at 6:11 AM, Brian Coca <bria...@gmail.com> wrote:
> - name: check exists
> stat: path={{hgrc}}
> ignore_errors: true
> register: hgrcfile
>
> - name: create .hgrc if necessary
> file: path={{ hgrc }} owner={{ user }} state=touch
> when: hgrcfile.failed
>
>
> On Tue, Mar 4, 2014 at 10:10 PM, Brian Coca <bria...@gmail.com> wrote:
>>
>> they are called tasks
>

Thanks. Tasks are fine, but distracting from logic. Lookup plugins are
just right for these kind of checks, but they only work on controlling
machine, so it would be nice to have a mechanism for remote lookups, no?

Michael DeHaan

unread,
Mar 5, 2014, 8:23:11 AM3/5/14
to ansible...@googlegroups.com
No, lookup plugins (except when they implement iterators) are a hack to fill in some rare but important use cases, most notably sourcing file data to the authorized_key module, and a few others.   They are rarely used.

I'd use the stat module here.






--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAPkN8xKwLQjYF3azievSU0FQb4qOxC_K%2BJFz2J9aWtCRg4i1bg%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages