For a specific case I need to echo a random string returned by ansible's function password_hash that contains multiple random $ signs (encryption method bcrypt). The echoed string is then piped into the next command.
Ideally I would just escape the entire string. If that is not possible, I would like to escape all $ signs. How is that possible? If there is an ansible native command that automatically escapes a variable, that would be fine, too.
Full task if needed
- name: Update Admin password
shell: "echo \"update users set passwd={{ zabbix_conf.admin_password|password_hash('bcrypt') }} where username='Admin'\" | mysql --user={{ zabbix_conf.db_user}} --password={{ zabbix_conf.db_password }} zabbix"
Currently doesn't work as expected, because the $ signs affect the echo to be empty.