I want to make the same (upload a release to github API with uri module).

I have seen an example posting the contents of a file:
- uri: url=https://your.jira.example.com/rest/api/2/issue/ 
       method=POST user=your_username password=your_pass 
       body="{{ lookup('file','issue.json') }}" force_basic_auth=yes

The problem seems that lookup want to read a utf8 file:
/usr/share/pyshared/ansible/runner/lookup_plugins/file.py
            ret.append(codecs.open(path, encoding="utf8").read().rstrip())

I was trying also something like:
  - name: read file
    shell: cat issue.rpm
    register: file

  - uri: url=http://localhost
         method=POST
         HEADER_Content-Type="application/octet-stream"
         body="{{ file.stdout }}"

But it doesn't work:
msg: this module requires key=value arguments ...


El viernes, 6 de junio de 2014 15:52:18 UTC+2, Guy Matz escribió:
>
> Hi!  How do you feel about something like this for the uri module?
>    # module.params section
>
>    # if body is a file URL, e.g. 'file:///bin/false', read it in and 
> replace the text of body with the binary contents of the file
>    if urlparse.urlparse(body).scheme == 'file':
>         try:
>             body = open(urlparse.urlparse(body).path, 'rb').read()
>         except Exception as e:
>             module.fail_json(msg="failed to open %s for body: %s" % 
> (urlparse.urlparse(body).path, str(e) ) )
>
> Should file location be relative to roles dir?
>
> Thanks a lot!!!!
>
> Guy
>
>
> On Saturday, May 31, 2014 12:28:28 PM UTC-4, Michael DeHaan wrote:
>>
>> All the arguments are passed on the command line for that module versus 
>> loaded form local files, so probably not.   Patches to accept a data file 
>> to read would be accepted.
>>
>>
>>
>>
>> On Thu, May 29, 2014 at 10:07 AM, Guy Matz <guy...@gmail.com> wrote:
>>
>>> Hi!  Anyone know if it's possible to test the upload of a binary file 
>>> using the uri module?  It doesn't look like httplib2 has this functionality 
>>> . . .
>>>
>>> Thanks,
>>> Guy
>>>  
>>> -- 
>>> 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/d2cf9f61-f941-411b-9bd4-db0e269efee7%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ansible-project/d2cf9f61-f941-411b-9bd4-db0e269efee7%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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/39e21355-cf12-465a-be14-fe16276f6b3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to