Il giorno giovedì 2 febbraio 2017 14:44:16 UTC+1, Brian Coca ha scritto:
>
> This will avoid any and all problems with my_key definition. 
>
>    with_file: "{{ (my_key is defined)|ternary(my_key|default('') + 
> '.pub', [])}}" 
>
>
> ---------- 
> Brian Coca 
>

Hi Brian,
thanks for your answer. I changed the yaml as you suggested:

- name: Configure key on remote host
  authorized_key:
    user: root
    key: "{{ item }}"
  with_file: "{{ (my_key is defined)|ternary(my_key|default('') + '.pub', 
[])}}"
  become: true
  when: do_the_test|bool

But it stills fail to locate the file:

TASK [bug_20919_bis : Configure key on remote host] 
****************************
task path: /home/rasca/Red-Hat/ansible/tests/roles/bug_20919_bis/tasks/main.
yml:12
 [WARNING]: Unable to find 'rasca.pub' in expected paths.


File lookup using None as file
fatal: [192.168.122.100]: FAILED! => {
    "failed": true, 
    "msg": "could not locate file in lookup: rasca.pub"
}
 to retry, use: --limit @/home/rasca/Red-Hat/ansible/tests/bug_20919_bis.
retry

So the problem here does not seem to be related at what is inside the 
variable passed to "with_file", but to the fact that independently from 
what's passed and from the "when:" variable, ansible looks for the file.

Thanks,

Raoul

-- 
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/a26f56a6-ccb5-4815-8ff5-64e3a044dae9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to