`
And I got an error “Get https://cr.yandex/v2/: unauthorized: Password is invalid - must be JSON key”.
When I ran “ansible-playbook” in verbose mode I saw that the content of the file “key.json” was transcoded – double quotes were changed to single quotes so it have become an invalid json string.
that's not what "caused" this. The problem is that Ansible interprets
your JSON file as a dictionary, parses it and passes it on as a
dictionary. What you've done is telling the docker_login module to no
longer convert it back to a string, but to keep it as a dictionary.
This will be passed on to the docker daemon as a dictionary (since
docker-py says it wants the password to be a string, but won't check
it). I don't know what the docker daemon will do with it. But this
rather looks like accidental behavior than what is intended.
So your question should be: how do I pass the contents of a JSON file
into the string parameter of a module without Ansible "destroying" it
(by interpreting it as a dictionary)? That's a question better for the
ansible-project google groups / mailing list.