Hi Olstad,
Thanks for your quick answer.
I have tried the lookup before and it throws some error related to utf-8.
That is why I had to use slurp.
Indeed, the file to decode is a .gz file which is received through SCP in a
base64 encoded format.
"msg": "An unhandled exception occurred while running the lookup plugin
'file'. Error was a <type 'exceptions.UnicodeDecodeError'>, original
message: 'utf8' codec can't decode byte 0x8b in position 1: invalid start
byte"
Regards
Karim




Le mer. 2 oct. 2019 à 13:30, Kai Stian Olstad <
ansible-project+l...@olstad.com> a écrit :

> On 02.10.2019 09:43, T Karim wrote:
> > Hi,
> > I am using the slurp module to retrieve and decode a binary file.
> > However,
> > I am getting wrong output with binary starting with 1F EF BD instead of
> > what I have in a decoded file with other tools: 1F 8B 08
> >
> > - name: Read backup file content
> >   slurp:
> >     src: "/tmp/{{ file }}"
> >   register: slurp_result
> >   delegate_to: localhost
> >
> > - name: Define file content
> >   set_fact:
> >     content: "{{slurp_result.content | b64decode }}"
>
> The filter b64decode doesn't support binary data, only ASCII.
>
> Since you are getting the file from localhost you can use lookup plugin
> file.
>
> {{ lookup('file', '/tmp/' ~ file) }}
>
> --
> Kai Stian Olstad
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4d68e82804dd3667bcbe8e9d34971b7d%40olstad.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGhHLeO%3DBTd5hc4%2BJ%3DRFqU%2Bxn9qVv_ANptC9Ua2D3QZTg3WAww%40mail.gmail.com.

Reply via email to