So tha vaule of k8s.definition.binaryData.binary-file.bin should be base64 encoded string.
My goal is to have universal ansible role and in every use there will be different file - so I can’t put there the string directly, instead I will pass the file as variable to the playbook.
The problem is that lookup file cannot read binary file - only utf8 text file.
Workaround I can now think of is that I can encode base64 file using shell module and register the result. Then I can read the base64 string from registered variable.
BUT I have to use shell module which is not recomended way (it is not best practice) and I’m trying not to use shell module.
In short, you cannot send binary data in a module argument.
If you can send base64 data instead of binary, you can use the slurp module to get the base64 encoded data. But you won’t be able to do {{ whatever.content|b64decode }} since that would try and produce binary data. Effectively you cannot send binary data through the templating engine.
I understand now, that lookup is templating engine which works only with utf8 text.
I don’t need to do {{ whatever.content|b64decode }} - decode.
I need only base64 encode binary file so I can pass the base64 string to k8s module.
slurp would be fine except that slurp fetch binary file from remote host. I have file on local host.