theforeman / foreman_ansible_inventory

Foreman dynamic inventory script for ansible - Now merged into Ansible itself
GNU General Public License v3.0
70 stars 31 forks source link

Complex types (JSON & YAML) #19

Closed arielsalvo closed 5 years ago

arielsalvo commented 8 years ago

Here's my implementation for the workaround in #17 to add complex data types. If you like it, feel free to take it ;)

Let me know what you think...

BTW, I used a different prefix than I was proposing but it can be customized in the ini file.

Regards! --Ariel

arielsalvo commented 8 years ago

Well, what would happen if you had valid JSON or YAML that you wanted to pass as string? It could be as simple as "{}", which is a valid empty JSON and it would be parse as {}. The same goes for YAML and it is worse since "---" and even "" are valid YAML and they are both parsed as null.

As I see it, you either have to escape the ones you want it to parse as I did or the ones that could be parsed and you don't want it to.