Kai Stian Olstad [27.03.2018 12:17]:
> On 27.03.2018 11:44, Werner Flamme wrote:
>> Hi all,
>>
>> I have a piece of code that gives an unexpected error:
>>
>> --- snip ---
>> - name: link the proper certificate issue directory
>>   file:
>>     src: '{{ item }}'
>>     dest: '/etc/mycert/current'
>>     state: link
>>     follow: yes
>>   with_first_found:
>>     - "/etc/mycert/von_2020"
>>     - "/etc/mycert/von_2019"
[...]

>> The "von_2016" would be correct on the host I use as ansible master, 
>> but not on the host (sapvhrq) where the play is executed.
>>
>> What do I do wrong here?
> 
> with_first_found always do lookup on localhost not the remote host.
> To get files on remote you need to use the find module.
> 

Oh, thanks, I didn't see this mentioned on the
<http://docs.ansible.com/ansible/latest/plugins/lookup/first_found.html>
page.

I see how I can use the find module. But how can I get the "latest"
directory from the find module?

Do I have to split into several "stat" statements, one per year,
beginning with 2020? Plus one "file" statement for each stat, to create
the desired symlink?

Since the "/etc/mycert" directory is a symlink too, pointing to a shared
filesystem, I try to use other variable, it works here, but not all of
my hosts can share this filesystem.

As dest, I use "/clusterdisk/sapdirs/{{ facter_myhostname }}/current",
and the with_first_found list now reads like

    - "/clusterdisk/sapdirs/{{ facter_myhostname }}/von_2020"
    - "/clusterdisk/sapdirs/{{ facter_myhostname }}/von_2019"

Regards,
Werner


-- 


-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6cc2f0b5-b4fe-d75d-c4f3-3cfdaf9bc8b5%40ufz.de.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to