0

When I issue the psql command like this in my playbook:

- name: Run psql to pull in initial config data
  become_method: sudo
  become: yes
  become_user: postgres
  command: psql -U postgres -w eclaim < /opt/eclaim_revamp/sql_scripts/initial_config.sql

It takes forever to complete, looks as though hang, but when I use shell, it can get through:

- name: Run psql to pull in initial data
  become_method: sudo
  become: yes
  become_user: postgres
  shell: psql -U postgres -w eclaim < /opt/eclaim_revamp/sql_scripts/initial_sql_script.sql

Can anybody tell me why ?

Muhammad Lukman Low
  • 8,177
  • 11
  • 44
  • 54

1 Answers1

2

From the documentation:

[The given command] will not be processed through the shell, so variables like $HOME and operations like "<", ">", "|", and "&" will not work (use the shell module if you need these features).

tlo
  • 1,571
  • 1
  • 25
  • 38
  • To add on why that is resulting in the observed behavior, the commands aren't fed in through the input file, and so Postgres is just waiting for input. – Xiong Chiamiov Jun 17 '16 at 22:27