Rather than using regex_replace or replace on the string, as a workaround, set the ITEM_TITLE environment variable, then use it in a double-quoted string. This should preserve behaviour of single quotes, apostrophes, and $ characters.
# mysql example_wp -e "select option_value from wp_options where option_name='blogname'"
+------------------------------------------------------------------+
| option_value |
+------------------------------------------------------------------+
| Title with Single Quote ' Double Quote " Dollar Sign $ |
+------------------------------------------------------------------+
I have a WordPress installation in my list of
wordpress_installs
that has a single-quote character'
in the title. An example would be something like:Currently this fails as the
wp-cli core install
command is invoked with the Ansible{{ item.item.title }}
variable in single quotes, making the shell command unbalanced (https://github.com/Oefenweb/ansible-wordpress/blob/master/tasks/core.yml#L53).Rather than using
regex_replace
orreplace
on the string, as a workaround, set theITEM_TITLE
environment variable, then use it in a double-quoted string. This should preserve behaviour of single quotes, apostrophes, and$
characters.Tested with the following config:
Resulting in the following database value:
I would be amenable to changing the environment variable name if there is a preference, but it should also only persist for this particular task in
core
as per the Ansible documentation (https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html).