I am getting code error in Ansible as below. please advise on this.
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0) Syntax Error while loading YAML. did not find expected key The error appears to be in '/root/ansible_code/roles/sample_exercise/tasks/main.yml': line 10, column 6, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: oracle_home: "{{ oracle_home.stdout }}" oracle_sid: "{{ dbname }}" ^ here We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }} Should be written as: with_items: - "{{ foo }}"
Code--
#- hosts: localhost
- hosts: 192.168.56.10
- debug:
msg: "{{ oracle_home.stdout }}"
- set_fact:
oracle_home: "{{ oracle_home.stdout }}"
oracle_sid: "{{ dbname }}"
- name: List PDB of given CDB
shell:
cmd: |
$ORACLE_HOME/bin/sqlplus / as sysdba <<EOF
select instance_name, status from v$instance
EOF
environment:
ORACLE_HOME: "{{ oracle_home }}"
ORACLE_SID: "{{ oracle_sid }}"
register: pdb
- name: List PDB
debug:
msg: "{{ pdb.stdout_lines|replace('\t', '') }}"