Ansible - add apt_key inline

Table of Contents

Using the aptkey module one can add an APT key with ansible. You can get the key from a remote server or from a file, or just a key ID. I got the request to do some stuff on a machine which was quite rescricted (so no HKP protocol) and I was asked not to place to many files on the machine. The aptkey was needed but it could not be a file, so using a YAML Literal Block Scalar I was able to add the key inline in the playbook. Not the best way to do it, but one of the many ways Ansible allows it.

ERROR! Syntax Error while loading YAML.
could not find expected ':'
The error appears to have been in '[...]roles/mediawiki/tasks/main.yml': line 8, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.6
^ here