As of 27-Oct-2016, this is the first result in Google when searching for "yaml rsa key", so I would like to add an answer on the specific syntax needed for RSA keys in Yaml.
If you include the key in a single line in the yaml file, there are no issues. If you want to split it in different lines for readability and you cannot accept newlines in the generated string, the only option seems to be double quotes with escape codes.
In my case, I needed a generated single-line, no-spaces string, since the key definition was being used by a templating engine to insert the key into a script variable. The following syntax will join each line with no spaces (please note the '\' on each line for removing the newlines):
yourKey: "-----BEGIN PUBLIC KEY-----\
xxx...\
yyy...\
zzz...\
-----END PUBLIC KEY-----"
result: "-----BEGIN PUBLIC KEY-----xxx...yyy...zzz...-----END PUBLIC KEY-----"
A very good reference on the formats for literals can be found here on SO: https://stackoverflow.com/a/21699210/4228798