On Fri, Oct 20, 2017 at 8:57 AM,  <jrvi...@gmail.com> wrote:
> Hola buenas,
>
> ¿por que se dan estas incongruencias al usar variables en el modulo copy en
> su argumento dest.?
>
>
> ---
> - hosts: localhost
>   vars:
>     PathLs: /etc/ansible/
>     Folder: /ansible/
>
>   tasks:
>     - name: Ejecuta script
>       script: "{{ PathLs }}ls.sh -al"
>       register: Log_Step1
>
>     - name: volcamos la salida a consola
>       debug: var=Log_Step1.stdout_lines
>
>     - name: volcamos la salida a fichero
>       copy:
>          content: |
>              {% for lines in  Log_Step1.stdout_lines %}
>              {{ lines }}
>              {% endfor %}
> #         dest: /etc/ansible/logls.txt          # usando esta linea ok
> #         dest: /etc/{{ Folder }}/logls.txt    # usando esta linea ok.
> #         dest: {{ PathLs }}logls.txt           # usando esto falla.
>          dest: "{{ PathLs }}logls.txt"          # usando esta linea ok.
>
>
> ¿por que en el caso de que comience por variable, tiene que usarse comillas,
> y en los otros casos no?
>
      AFAIK 
(http://docs.ansible.com/ansible/latest/playbooks_variables.html#hey-wait-a-yaml-gotcha),
you should use quotes around paths and other variables to guarantee
they are properly expanded. Out of curiosity, you could print {{
PathLs }}logls.txt  with and without quotes (say, using a debug
statement) to see how different they are.

> Un saludo.
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5f4b362a-f71d-4f01-b6e1-5e329ce1a1ab%40googlegroups.com.
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAHEKYV4HZvAhf-YsYRx3Ngnm78UWSzrUm0Qv8utaFg49kG1igA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to