Using Ansible how to connect Oracle DB on Linux & run command "show pdb" to display oracle pluggable DB, "shutdown immediate" to stop DB and start DB

Hi All,
Using Ansible how to connect Oracle DB on Linux & run command “show pdb” to display oracle pluggable DB, “shutdown immediate” to stop DB and start DB.

Code: - name: Run show pdbs
shell: |
{{ oracle_home }}/bin/sqlplus / as sysdba <<EOF
show pdbs;
exit
EOF
register: query_output

  • name: Display query output
    debug:
    msg: “{{ query_output.stdout_lines }}”

Its getting failed with below error:

fatal: [10.192.90.43]: FAILED! => {“changed”: true, “cmd”: “"{‘stderr_lines’: , u’changed’: True, u’end’: u’2023-07-22 15:05:49.418929’, ‘failed’: False, u’stdout’: u’/u01/app/oracle/product/19.3.0.0/db_1’, u’cmd’: u"cat /etc/oratab | egrep -v ‘^#|^$’ | grep -v ASM | cut -d ‘:’ -f2", u’rc’: 0, u’start’: u’2023-07-22 15:05:49.413535’, u’stderr’: u’‘, u’delta’: u’0:00:00.005394’, ‘stdout_lines’: [u’/u01/app/oracle/product/19.3.0.0/db_1’]}/bin/sqlplus / as sysdba <<EOF\nshow pdbs;\nexit\nEOF"\n”, “delta”: “0:00:00.005358”, “end”: “2023-07-22 15:05:52.954037”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2023-07-22 15:05:52.948679”, “stderr”: “/bin/sh: {‘stderr_lines’: , u’changed’: True, u’end’: u’2023-07-22 15:05:49.418929’, ‘failed’: False, u’stdout’: u’/u01/app/oracle/product/19.3.0.0/db_1’, u’cmd’: ucat: No such file or directory\ncut: fields are numbered from 1\nTry ‘cut --help’ for more information.”, “stderr_lines”: [“/bin/sh: {‘stderr_lines’: , u’changed’: True, u’end’: u’2023-07-22 15:05:49.418929’, ‘failed’: False, u’stdout’: u’/u01/app/oracle/product/19.3.0.0/db_1’, u’cmd’: ucat: No such file or directory”, “cut: fields are numbered from 1”, “Try ‘cut --help’ for more information.”], “stdout”: “”, “stdout_lines”: }

Anyone please guide.

Several things seem to be off with your output, it looks like a
recursive copy into itself, aside from that, the base error does not
seem to match the commands shown:

'cmd': ucat: No such file or directory", "cut: fields are numbered
from 1", "Try 'cut --help' for more information.

Looks like typo in a shell command/script (meant `cat`?) or `ucat` is
not in the PATH

Thank you for the response. what is the correct code I have to use?