template module bombing out

44 views
Skip to first unread message

John Oliver

unread,
Aug 7, 2014, 5:41:23 PM8/7/14
to ansible...@googlegroups.com
ansible 1.6.10

This task:

- name: Copy admin pwd chg ldif to target
  template: src=admin-pwd-chg.ldif.j2 dest=/tmp/

is leaving /tmp/admin-pwd-chg.ldif.j2 instead of admin-pwd-chg.ldif  The variables in it are being expanded.

-vvvv output:

TASK: [apacheds | Copy admin pwd chg ldif to target] ************************** 
<jedis-test> ESTABLISH CONNECTION FOR USER: joliver
<jedis-test> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/joliver/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'jedis-test', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998 && echo $HOME/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998'"]
<jedis-test> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/joliver/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'jedis-test', u'/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=kwyctxvepfhnnbaahrwvljxgtsdvpnur] password: " -u root /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-kwyctxvepfhnnbaahrwvljxgtsdvpnur; rc=0; [ -r "/tmp/admin-pwd-chg.ldif.j2" ] || rc=2; [ -f "/tmp/admin-pwd-chg.ldif.j2" ] || rc=1; [ -d "/tmp/admin-pwd-chg.ldif.j2" ] && echo 3 && exit 0; (/usr/bin/md5sum /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (/sbin/md5sum -q /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (/usr/bin/digest -a md5 /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (/sbin/md5 -q /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (/usr/bin/md5 -n /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (/bin/md5 -q /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (/usr/bin/csum -h MD5 /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (/bin/csum -h MD5 /tmp/admin-pwd-chg.ldif.j2 2>/dev/null) || (echo "${rc} /tmp/admin-pwd-chg.ldif.j2")\'"\'"\'\'']
<jedis-test> PUT /var/folders/67/dk8m_22d413fhslkhh4dwkzr0000gn/T/tmpkBftoy TO /home/joliver/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998/source
<jedis-test> PUT /var/folders/67/dk8m_22d413fhslkhh4dwkzr0000gn/T/tmpKQfnIR TO /home/joliver/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998/copy
<jedis-test> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/joliver/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'jedis-test', u'/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=wdssxeblwbwzcnbalsyidqzsjgqmxxcc] password: " -u root /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-wdssxeblwbwzcnbalsyidqzsjgqmxxcc; LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /home/joliver/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998/copy; rm -rf /home/joliver/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998/ >/dev/null 2>&1\'"\'"\'\'']
changed: [jedis-test] => {"changed": true, "dest": "/tmp/admin-pwd-chg.ldif.j2", "gid": 0, "group": "root", "md5sum": "47ebafe65449834031c310ceb02b9310", "mode": "0611", "owner": "root", "secontext": "unconfined_u:object_r:user_home_t:s0", "size": 90, "src": "/home/joliver/.ansible/tmp/ansible-tmp-1407442699.07-10863228717998/source", "state": "file", "uid": 0}

David Karban

unread,
Aug 8, 2014, 9:32:19 AM8/8/14
to ansible...@googlegroups.com
Hi,

AFAIK it is correct and ansible is doing it at least from 1.1 (when I started with it). If you set only path, template file name is just copied as is in src argument.

template: src=admin-pwd-chg.ldif.j2 dest=/tmp/admin-pwd-chg.ldif

will work.

David



--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a03cc003-f0de-4a22-a765-b34abe85a5a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
David Karban
Specialista na správu linuxových serverů
www.karban.eu

Michael DeHaan

unread,
Aug 8, 2014, 10:43:27 AM8/8/14
to ansible...@googlegroups.com
When you don't specify a destination path, it is going to use the filename to decide the filename of the output.

The solution would be to specify the full path to the destination file.





Reply all
Reply to author
Forward
0 new messages