# PSQL command execution failing due to special characters in password variable

**URL:** <https://forum.ansible.com/t/psql-command-execution-failing-due-to-special-characters-in-password-variable/37360>\
**Category:** Ansible Developer\
**Created:** [November 16, 2022, 7:31pm UTC](https://forum.ansible.com/t/psql-command-execution-failing-due-to-special-characters-in-password-variable/37360 "2022-11-16T19:31:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj5](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@Raj5](https://forum.ansible.com/u/Raj5)\
**Post date:** [November 16, 2022, 7:31pm UTC](https://forum.ansible.com/t/psql-command-execution-failing-due-to-special-characters-in-password-variable/37360/1 "2022-11-16T19:31:28Z")

</div>

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.
