Incidentally, I also tried using the file lookup plugin on a base64-encoded
tar file, and then filtering that with Jinja2’s b64decode filter. That also
fails, though I think it does so at a later stage than trying to use the
file lookup plugin on a binary file. Using the b64decode filter on a
looked-up base64-encoded file, one gets an error whose stack trace ends
something like this:
File
"/usr/local/Cellar/ansible/1.8.2/libexec/lib/python2.7/site-packages/ansible/utils/template.py",
line 362, in template_from_string
res = jinja2.utils.concat(rf)
File "<template>", line 7, in root
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfd in position 0:
ordinal not in range(128)
I then thought I’d do a little experiment, and provide the user data as a
literal (copy-and-pasted) string of base64-encoded data, again filtered
with the Jinga2 b64decode filter, like this:
user_data: "{{ '/Td6WFoAAATm1rRGA … VZiascRn+wIAAAAABFla' | b64decode }}"
That took the file lookup plugin out of the equation, but resulted in the
same error.
I next tried the pipe lookup plugin (with ‘cat my-binary-file’), but that
also fails in the same way as the file lookup plugin. Looking at the source
code, the pipe lookup plugin follows the file lookup one and
unconditionally tries to decode the output from the command as a UTF-8
encoded string.
I provisionally conclude from all this that Ansible generally doesn’t want
to handle binary parameter values. That seems limiting. I suppose one
solution to my specific problem (without fixing the wider issue) would be
for the ec2 module to accept something like a user_data_file parameter (as
an alternative to user_data), which would specify a local file whose
content was to be used without any processing at all as an opaque user data
binary object. In fact, that’s pretty much exactly what I want, as I could
give it the FreeBSD configinit .tar file directly.
I am still hoping that someone has a solution that will enable binary user
data to be provided to an instance.
Again, my thanks in advance for any assistance.
--
Daniel
On Tuesday, 23 December 2014 23:06:38 UTC, Daniel Neades wrote:
>
> On Saturday, 25 October 2014 20:33:32 UTC+1, Chris Church wrote:
>>
>> The file lookup plugin is your friend.
>>
>
> It is – if one wishes to supply text-based user data. Unfortunately, I
> have a requirement to provide a binary blob of user data, and the file
> lookup plugin does not seem to handle that – looking at the source code, it
> expects the file to be a UTF8-encoded text file.
>
> <snip>
>
--
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/9708972a-8a15-4819-9837-4a172b9cf608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.