"Since which version has that been deprecated and when did the behaviour change? I'm running 1.4.5 and cannot get rid of the deprecation warnings because "with_first_found", in 1.4.5, cannot iterate over a file not found. "
I'm not sure what you mean about a behavior change, but first_available_file is still part of the software. ""with_first_found", in 1.4.5, cannot iterate over a file not found." Not sure what this means, because it finds the first file it can find, and will use that one, just like the other. Can you explain more? On Wed, May 14, 2014 at 9:43 AM, Bas Meijer <[email protected]> wrote: > Since which version has that been deprecated and when did the behaviour > change? I'm running 1.4.5 and cannot get rid of the deprecation warnings > because "with_first_found", in 1.4.5, cannot iterate over a file not found. > > > Expected behaviour mentioned by Serge "then if no match, the task would > get skipped." > Observed behaviour when there is no template named etc-hosts.backend.j2, > then it crashes with: > > fatal: [backend] => One or more undefined variables: 'item' is undefined > > If there is no alternative construct that works in 1.4.5, then there is a > problem in the backward-compatibility period because the deprecation cannot > be fixed before upgrade. > > > > > On May 14, 2014, at 14:26, Michael DeHaan <[email protected]> wrote: > > Yep, first_available_file is quite deprecated, use "with_first_found" > instead, which is the replacement in all recent versions of Ansible. > > That's probably why you aren't seeing any references to it. I'm not sure > what was going on with search. > > > > > > On Wed, May 14, 2014 at 8:15 AM, Bas Meijer <[email protected]>wrote: > >> Sililar to the example on http://docs.ansible.com/playbooks_loops.html >> >> >> - name: build and write /etc/hosts file >> action: template src=templates/{{ item }} dest=/etc/hosts owner=root >> group=root mode=0644 >> with_first_found: >> - "etc-hosts.{{ansible_hostname}}.j2" >> - "etc-hosts.j2" >> >> Ansible 1.4.5 fails with the newer 'with_first_found' >> fatal: [backend] => {'msg': 'One or more items failed.', 'failed': True, >> 'changed': False, 'results': [{'msg': 'unable to >> read /home/bas/code/iwelcome-ansible/playbooks/hosts/templates/None', >> 'failed': True}]} >> >> When I replace 'with_first_found' with 'first_available_file' it fails in >> a different way: >> fatal: [backend] => One or more undefined variables: 'item' is undefined >> >> >> On May 14, 2014, at 14:01, Serge van Ginderachter < >> [email protected]> wrote: >> >> >> On 14 May 2014 13:42, Bas Meijer <[email protected]> wrote: >> >>> PROBLEM: In the playbook below, Ansible 1.4.5 shows 'DEPRECATION >>> WARNING' when I use $item, and 'undefined variables' when in use >>> >>> {{item}}. >> >> >> >> >> {{item}} is the right syntax >> >> undefined variables is another problem, is it possible you get no match >> for first_available_file? >> >> You might want to use with_first_found instead of the >> older first_available_file though, then if no match, the task would get >> skipped. >> >> >> >> Serge >> >> >> >> -- >> 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/CAEhzMJD8iiwTqUJhC%3DX5QNB1zQoz6p8DOodVFvZau-X71yMy4Q%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAEhzMJD8iiwTqUJhC%3DX5QNB1zQoz6p8DOodVFvZau-X71yMy4Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> >> >> >> -- >> 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/C3D37BEF-503D-41D4-ACE4-20B3D0A177DD%40iwelcome.com<https://groups.google.com/d/msgid/ansible-project/C3D37BEF-503D-41D4-ACE4-20B3D0A177DD%40iwelcome.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > 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/CA%2BnsWgzB2%2Bk0h%3Df3%2BW%2BcBzWiKdpaSrm6%3D-77OKZaxKLRzfbiuw%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzB2%2Bk0h%3Df3%2BW%2BcBzWiKdpaSrm6%3D-77OKZaxKLRzfbiuw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > > > -- > 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/BFEA75AB-7CBB-4698-BCD1-F360D94C83CE%40iwelcome.com<https://groups.google.com/d/msgid/ansible-project/BFEA75AB-7CBB-4698-BCD1-F360D94C83CE%40iwelcome.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/CA%2BnsWgwGahmpNh%3DPi6WgWVr_ywNw0w0cGYNmWf--wCdFXOAVgQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
