PSQL command execution failing due to special characters in password variable

Hello Ansible Team,

We have a playbook where it can execute SQL commands against Aurora Database.
Here is the sample playbook

Playbook Execution command:
ansible-playbook CreateSchema.yml -i inventory/dev -l dev.db -e password=‘Lwd)1[pH5a=Xnv`C(1v|fI’ --connection=local

Here is the task:

  • name: Run SQL command

shell: source ~/.bash_profile && PGPASSWORD=“{{ password }}” psql -h {{ RDS_URL }} -p 5432 -f Create.sql -U {{ userName }} -v ci=true {{ DB_NAME }}
delegate_to: localhost
register: create
args:
chdir: roles/createsql/files/fullload
tags: schema

fatal: [Dbinstance → localhost]: FAILED! => {“changed”: true, “cmd”: “source ~/.bash_profile && PGPASSWORD=Lwd)1[pH5a=Xnv`C(1v|fI psql -h Dbinstance -p 5432 -f Create.sql -U postgres -v ci=true dbname”, “delta”: “0:00:00.090742”, “end”: “2022-11-16 19:16:59.202298”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2022-11-16 19:16:59.111556”, “stderr”: “/bin/sh: -c: line 0: syntax error near unexpected token`)‘\n/bin/sh: -c: line 0: `source ~/.bash_profile && PGPASSWORD=Lwd)1[pH5a=Xnv`C(1v|fI psql -h Dbinstance -p 5432 -f Create.sql -U postgres -v ci=true dbname’”, “stderr_lines”: [“/bin/sh: -c: line 0: syntax error near unexpected token `)'”, “/bin/sh: -c: line 0: `source ~/.bash_profile && PGPASSWORD=Lwd)1[pH5a=Xnv`C(1v|fI psql -h Dbinstance -p 5432 -f Create.sql -U postgres -v ci=true dbname’”], “stdout”: “”, “stdout_lines”: }

Looks like Shell is not interpreting the password correctly here, the password not working without single quotes. Can anyone share their thoughts? Either we need to pass the quotes or need a way to pass the password with special characters.

Thanks in advance.