Thank you Jordan.  I did not know you could set ansible_remote_tmp at the 
task level.  I will try that.  As a work around before I saw your answer, I 
just build a filter to return the md5 as follows:

        - name: Calculate md5sum from local file
          set_fact: qcow_md5sum="{{ qcow_filepath|getmd5sum() }}"
          run_once: true


import subprocess


def getmd5sum (filename):

    try:
      output = subprocess.check_output(['md5sum',filename])
    except:
      print "Problem determining md5sum on file ", filename
      return 1

    tmplist = output.split()
    md5sum = tmplist[0]

    return md5sum


class FilterModule(object):
    def filters(self):
        return {'getmd5sum': getmd5sum}


On Wednesday, December 19, 2018 at 11:01:23 PM UTC-5, Jordan Borean wrote:
>
> ansible_remote_tmp is a shell option so it isn't affected by delegate_to 
> as you have seen it will use what was set before. To get around this you 
> can set ansible_remote_tmp on the task itself to a temp dir that exists on 
> the local host like so;
>
> - name: Calculate md5sum from local file
>   stat:
>     path: "{{ src_dir }}/{{ qcow_file_name }}"
>     get_checksum: yes
>     checksum_algorithm: md5
>   register: file_stats
>   run_once: True
>   delegate_to: localhost
>   vars:
>     ansible_remote_tmp: ~/.ansible/tmp
>
> Thanks
>
> Jordan
>

-- 
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/0c47548e-06e1-469f-9f68-85f73e5b9ba7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to