# Emcli command not working through ansible playbook

**URL:** <https://forum.ansible.com/t/emcli-command-not-working-through-ansible-playbook/44626>\
**Category:** Get Help\
**Tags:** aws\
**Created:** [October 7, 2025, 3:58pm UTC](https://forum.ansible.com/t/emcli-command-not-working-through-ansible-playbook/44626 "2025-10-07T15:58:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madan\_Kumar\_Dusarlap](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/madan_kumar_dusarlap/32/7731_2.png) [@Madan\_Kumar\_Dusarlap](https://forum.ansible.com/u/Madan_Kumar_Dusarlap)\
**Post date:** [October 7, 2025, 3:58pm UTC](https://forum.ansible.com/t/emcli-command-not-working-through-ansible-playbook/44626/1 "2025-10-07T15:58:15Z")

</div>

Hi Team,  
emcli commands are used in ansible playbook and it is output properly but when testing it OMS server (OEM installed server). it is thrown an error and also GUI getting error.

Error:  
[oracle@itlxprddb02 ~]$ /opt/oracle/product/em/em1350/bin/emcli sync  
Synchronized successfully  
[oracle@itlxprddb02 ~]$  
[oracle@itlxprddb02 ~]$ /opt/oracle/product/em/em1350/bin/emcli test\_named\_credential -cred\_names=DSCRDEV\_SYSTEM\_NORMAL -target\_name=dscrdev -target\_type=oracle\_database  
Credential test failed for dscrdev:oracle\_database  
Authentication failed ORA-01017: invalid username/password; logon denied

The Connect Descriptor was (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = [orarheldev02.exelixis.com](http://orarheldev02.exelixis.com))(PORT = 1522))(CONNECT\_DATA = (SID = dscrdev)(SERVER = DEDICATED)))

Ansible script:  
for cred in {{ clean\_named\_cred\_list\_oms | join(’ ‘) }}; do  
if [[“${cred^^}” == “${named\_cred^^}”]]; then  
match\_cred=“$cred”  
echo “$match\_cred”  
/opt/oracle/product/em/em1350/bin/emcli logout \> /dev/null 2\>&1  
/opt/oracle/product/em/em1350/bin/emcli login -username={{ oms\_user }} -password={{ oms\_pwd }}  
/opt/oracle/product/em/em1350/bin/emcli sync  
/opt/oracle/product/em/em1350/bin/emcli clear\_cache  
/opt/oracle/product/em/em1350/bin/emcli sync  
db\_name\_cred=$(echo “$match\_cred” | cut -d’\_’ -f1)  
ACTUAL\_TARGET\_CRED=$(/opt/oracle/product/em/em1350/bin/emcli get\_targets | awk -v tname=“$db\_name\_cred” ‘$3 == “{{ oms\_target\_type }}” && tolower($4) == tolower(tname) {print $4}’ | head -1)  
NAMED\_CRED\_OUTPUT=$(/opt/oracle/product/em/em1350/bin/emcli modify\_named\_credential -cred\_name=$match\_cred -attributes=“DBUserName:{{ db\_user }};DBPassword:‘{{ item.new\_password }}’;DBRole:normal” 2\>&1)  
/opt/oracle/product/em/em1350/bin/emcli sync  
NAME\_CRED\_TEST\_OUTPUT=$(/opt/oracle/product/em/em1350/bin/emcli test\_named\_credential -cred\_names=$match\_cred -target\_name=$ACTUAL\_TARGET\_CRED -target\_type=“{{ oms\_target\_type }}” 2\>&1)  
if echo $NAMED\_CRED\_OUTPUT | grep -qi “error” || echo $NAMED\_CRED\_TEST\_OUTPUT | grep -qi “error” ; then  
modify\_status=“failed”  
else  
modify\_status=“success”  
fi  
fi  
done

output of ansible playbook:

“stdout\_lines”: [  
“Login successful”,  
“Synchronized successfully”,  
“DBATEST\_SYSTEM\_NORMAL”,  
“Login successful”,  
“Synchronized successfully”,  
“system update status: success - named cred modify status: success”,  
"system user output:- Successfully submitted a job to change the password in Enterprise Manager and on the target database: "dbatest" “,  
“Execute "emcli get\_jobs -job\_id=408009BBE51517E1E06351041DACF1AC" to check the status of the job. “,  
“Search for job name "CHANGE\_PWD\_JOB\_1759764228581" on the Jobs home page to check job execution details.”,  
“named cred output:- Credential updated.”,  
“name cred test output:- Credentials "DBATEST\_SYSTEM\_NORMAL:SYSMAN" tested successfully”,  
“{”,  
" "ARN": "arn:aws:secretsmanager:us-west-2:161066317442:secret:oracle\_common\_system\_current-ssCPuy",”,  
" "Name": "oracle\_common\_system\_current",”,  
" "VersionId": "73834a98-cc11-4e4d-bd44-cd82d7c2fd25"”,  
“}”,  
“dbname:dbatest,dbtype:N,current\_password:uQ#OeSk##lJwIm#r#8HnFgr9”  
]
