I have a DB tool that I want to call in ansible. The DB tool can take SQL commands passed in between quotes. The problem is that I cannot get the escapes right for this work.
The command would like this in a normal interactive way (as linuxuser)
dbtool -u DBUSER -p DBPWD "backup data using file ('/backup/path/prefi_')"
I tried something like this in ansible
tasks:
- name: something
become: yes
become_method: sudo
shell: "runuser -l {{ linuxuser }} -c '/path/to/dbtool/dbtool -u DBUSER -p DBPWD \"backup data using file ('/backup/path/prefix_')\"'"
I tried escaping different ways, the dbtool just complains about the " or the ' one way or another.
Any hint would be appreciated.
PS: I cannot use become_user: {{ linuxuser }} because of other reasons.
PS2: dbtool only works as {{ linuxuser }} because of the various libraries in environment.