AWX unable to execute a playbook calling a shell script

174 views
Skip to first unread message

Fernando Scarlazzari de Oliveira

unread,
Oct 10, 2019, 7:05:06 AM10/10/19
to AWX 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=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SSH_CLIENT=xxxxxxxxxxxxxxxxxxxxx
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=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"SSH_CLIENT=xxxxxxxxxxxxxxxxxxxxx",
"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.
Thank you in advance for any help.

David Maple

unread,
Oct 10, 2019, 12:51:52 PM10/10/19
to Fernando Scarlazzari de Oliveira, AWX Project
Does the script exist inside the awx containers filesystem, or just on the host filesystem?

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/9414ffeb-34af-40f4-b683-929b7d7ad223%40googlegroups.com.

Fernando Scarlazzari de Oliveira

unread,
Oct 10, 2019, 4:40:42 PM10/10/19
to David Maple, AWX Project
It exists only on the host running AWX.

David Maple

unread,
Oct 10, 2019, 6:26:41 PM10/10/19
to Fernando Scarlazzari de Oliveira, AWX Project
Normal installation of AWX runs in containers.  So, you need to make sure that GTA directory is mounted inside the task container so your playbook can reach it.  That should get it working for you.

Dave

Fernando Scarlazzari de Oliveira

unread,
Oct 11, 2019, 8:29:19 AM10/11/19
to David Maple, AWX Project
Dave/All

     Unfortunately I'm not using docker. I have installed this instance without docker for a POC in the company I work.

     Since it works from command line, my guess is that AWS is messing something up with the extra vars, or ssh options it adds to the playbook execution, but so far I was unable to pin down the problem.
Reply all
Reply to author
Forward
0 new messages