Did you check the link I gave you in my reply? On Fri, Oct 20, 2017 at 9:59 AM, <[email protected]> wrote: > check 1: with and without quotes are the same > > --- > - hosts: localhost > vars: > PathLs: /etc/ansible/ > Folder: /ansible/ > tasks: > - name: curiosidad con comillas > debug: > msg: "{{ PathLs }}logls.txt" > > - name: curiosidad igual > debug: > msg: esto es sin comillas {{ PathLs }}logls.txt > > > result check1: > > > * > ok: [172.18.77.66] => { > "msg": "/etc/ansible/logls.txt" > } > > TASK [curiosidad igual] > *************************************************************************************** > ok: [172.18.77.66] => { > "msg": "esto es sin comillas /etc/ansible/logls.txt" > } > > > check 2: with quotation marks at the beginning of the sentence return error: > tasks: > - name: curiosidad con comillas > debug: > msg: {{ PathLs }}logls.txt > > > result check2: > ERROR! Syntax Error while loading YAML. > > > The error appears to have been in '/etc/ansible/playbooks/*******.yml': line > 23, column 27, but may > be elsewhere in the file depending on the exact syntax problem. > > The offending line appears to be: > > debug: > msg: {{ PathLs }}logls.txt > ^ here > We could be wrong, but this one looks like it might be an issue with > missing quotes. Always quote template expression brackets when they > start a value. For instance: > > with_items: > - {{ foo }} > > Should be written as: > > with_items: > - "{{ foo }}" > > > > > > El viernes, 20 de octubre de 2017, 15:28:06 (UTC+2), Mauricio Tavares > escribió: >> >> On Fri, Oct 20, 2017 at 8:57 AM, <[email protected]> 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 [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/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 [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/b4418e47-4e26-4920-9586-d287df55d2dd%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 [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/CAHEKYV42L8KCGk5EH4eAr%2BLK3RDBK0S9a%3DC1RAJYaBs4nHxMnQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
