How do I prevent ansible templates from being confused by the content they receive? How do I prevent ansible templates from being confused by the content they receive? wordpress wordpress

How do I prevent ansible templates from being confused by the content they receive?


Escaping certain characters is going to be difficult, because not only would the uri module need to support that, but the templating engine engine would have to unescape as well.

Instead, here's a workaround:

Modify the task so the content is saved to a file instead of a variable:

- name: retrieve new wordpress keys and salts  uri:    url: "https://api.wordpress.org/secret-key/1.1/salt/"    method: GET    dest: wp_keys.php    return_content: yes

Then add a line to your wp-config.php.j2 template that includes wp_keys.php.


So I ended up abandoning the template solution. Instead I used wp-cli to generate the wp-config.php file for me. I only did this because the template solution would randomly fail to work with the template getting confused by the content it was receiving.