AWX unable to execute a playbook with a shell script

23 views
Skip to first unread message

Fernando Scarlazzari de Oliveira

unread,
Oct 9, 2019, 7:42:10 AM10/9/19
to Ansible Project
Hello friends,

    I have a simple playbook that calls a shell script:

---
- name: Transporte GTA ECC PRD
  hosts: localhost
  tasks:
       - script: /var/lib/awx/projects/GTA/trans_ecc.sh
         register: output
       - debug: var=output.stdout_lines

The script sets and checks environment variables on a remote host going through a jump server, like so (notice the path where the script is):

 cat /var/lib/awx/projects/GTA/trans_ecc.sh

#!/bin/sh
ssh -n -J ans...@xxx.xxx.xxx.1 prd...@yyy.yyy.yyy.2 ". ~/.profile ;env"

Running the script manually works:

/var/lib/awx/projects/GTA/trans_ecc.sh
stty: tcgetattr: Not a typewriter
_=/usr/bin/env
LANG=en_US
THREAD=NOPS
LOGIN=prdadm
CLCMD_PASSTHRU=1
PATH=/oracle/PRD/12102/bin:/usr/java14_64/jre/bin:.:/home/prdadm:/usr/sap/PRD/SYS/exe/run:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr/java5/bin
NLS_LANG=AMERICAN_AMERICA.WE8DEC
RSEC_SSFS_KEYPATH=/usr/sap/PRD/SYS/global/security/rsecssfs/key
ORACLE_BASE=/oracle
LC__FASTMSG=true
LOGNAME=prdadm
MAIL=/var/spool/mail/prdadm
dbs_ora_tnsname=PRD
ORACLE_SID=PRD
LOCPATH=/usr/lib/nls/loc
DB_SID=PRD
DIR_LIBRARY=/usr/sap/PRD/SYS/exe/run
USER=prdadm
AUTHSTATE=CENTRIFYDC
TNS_ADMIN=/usr/sap/PRD/SYS/profile/oracle
IBM_JAVA_OPTIONS=-Xmx256M -Xj9
dbs_ora_schema=SAPSR3
SHELL=/bin/ksh
ODMDIR=/etc/objrepos
JAVA_HOME=/usr/java14_64/jre
CLUSTER_OVERRIDE=yes
SAPDATA_HOME=/oracle/PRD
RSEC_SSFS_DATAPATH=/usr/sap/PRD/SYS/global/security/rsecssfs/data
HOME=/home/prdadm
SSH_CONNECTION=10.99.245.10 43104 10.99.245.13 22
SSH_CLIENT=10.99.245.10 43104 22
ORACLE_HOME=/oracle/PRD/12102
rsdb_ssfs_connect=1
PWD=/home/prdadm
ALERTLOG=/oracle/PRD/saptrace/background/alert_PRD.log
TZ=America/Sao_Paulo
dbms_type=ORA
SAPSYSTEMNAME=PRD
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/%l.%c/%N:/usr/lib/nls/msg/%l.%c/%N.cat
LIBPATH=/usr/lib:/lib:/usr/sap/PRD/SYS/exe/run:/oracle/client/11x_64/instantclient

executing the playbook on command line also works:

ansible-playbook transporte_ecc_prd.yml

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'




PLAY [Transporte GTA ECC PRD] ***************************************************************************************************************************************************************************************************************


TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************

ok: [localhost]


TASK [script] *******************************************************************************************************************************************************************************************************************************
changed: [localhost]


TASK [debug] ********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"output.stdout_lines": [
"_=/usr/bin/env",
"LANG=en_US",
"THREAD=NOPS",
"LOGIN=prdadm",
"CLCMD_PASSTHRU=1",
"PATH=/oracle/PRD/12102/bin:/usr/java14_64/jre/bin:.:/home/prdadm:/usr/sap/PRD/SYS/exe/run:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr/java5/bin",
"NLS_LANG=AMERICAN_AMERICA.WE8DEC",
"RSEC_SSFS_KEYPATH=/usr/sap/PRD/SYS/global/security/rsecssfs/key",
"ORACLE_BASE=/oracle",
"LC__FASTMSG=true",
"LOGNAME=prdadm",
"MAIL=/var/spool/mail/prdadm",
"dbs_ora_tnsname=PRD",
"ORACLE_SID=PRD",
"LOCPATH=/usr/lib/nls/loc",
"DB_SID=PRD",
"DIR_LIBRARY=/usr/sap/PRD/SYS/exe/run",
"USER=prdadm",
"AUTHSTATE=CENTRIFYDC",
"TNS_ADMIN=/usr/sap/PRD/SYS/profile/oracle",
"IBM_JAVA_OPTIONS=-Xmx256M -Xj9",
"dbs_ora_schema=SAPSR3",
"SHELL=/bin/ksh",
"ODMDIR=/etc/objrepos",
"JAVA_HOME=/usr/java14_64/jre",
"CLUSTER_OVERRIDE=yes",
"SAPDATA_HOME=/oracle/PRD",
"RSEC_SSFS_DATAPATH=/usr/sap/PRD/SYS/global/security/rsecssfs/data",
"HOME=/home/prdadm",
"SSH_CONNECTION=10.99.245.10 43108 10.99.245.13 22",
"SSH_CLIENT=10.99.245.10 43108 22",
"ORACLE_HOME=/oracle/PRD/12102",
"rsdb_ssfs_connect=1",
"PWD=/home/prdadm",
"ALERTLOG=/oracle/PRD/saptrace/background/alert_PRD.log",
"TZ=America/Sao_Paulo",
"dbms_type=ORA",
"SAPSYSTEMNAME=PRD",
"NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/%l.%c/%N:/usr/lib/nls/msg/%l.%c/%N.cat",
"LIBPATH=/usr/lib:/lib:/usr/sap/PRD/SYS/exe/run:/oracle/client/11x_64/instantclient"
]
}



PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0



But when a execute it from AWX:

Using /etc/ansible/ansible.cfg as config file
2
[WARNING]: provided hosts list is empty, only localhost is available. Note
3
that the implicit localhost does not match 'all'
4
5
6
PLAY [Transporte GTA ECC PRD] **************************************************
08:05:38
7
8
TASK [Gathering Facts] *********************************************************
08:05:38
9
ok: [localhost]
10
11
TASK [script] ******************************************************************
08:05:39
12
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Could not find or access '/var/lib/awx/projects/GTA/trans_ecc.sh' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}
13
14
PLAY RECAP *********************************************************************
08:05:39
15
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

I have e chmoded to 777 the complete tree but still the error occurs.

Kai Stian Olstad

unread,
Oct 10, 2019, 6:38:32 AM10/10/19
to ansible...@googlegroups.com
On 09.10.2019 13:42, Fernando Scarlazzari de Oliveira wrote:
> But when a execute it from AWX:

This list is for Ansible only and not AWX, AWX has it own list.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages