# How to execute a script from AWX via EE on a remote server

**URL:** <https://forum.ansible.com/t/how-to-execute-a-script-from-awx-via-ee-on-a-remote-server/38552>\
**Category:** AWX Project\
**Tags:** awx, ee\
**Created:** [October 27, 2023, 11:33am UTC](https://forum.ansible.com/t/how-to-execute-a-script-from-awx-via-ee-on-a-remote-server/38552 "2023-10-27T11:33:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Albert\_Short](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Albert\_Short](https://forum.ansible.com/u/Albert_Short)\
**Post date:** [October 27, 2023, 11:33am UTC](https://forum.ansible.com/t/how-to-execute-a-script-from-awx-via-ee-on-a-remote-server/38552/1 "2023-10-27T11:33:53Z")

</div>

All,

Scenario/Current working solution  
I have created an Ansible playbook that makes a call to a python script on a specific host (script oly present on this host)  
This script works & does what it needs to on the specific host.  
This host serves as our build server which also provides the location for POAP scripts, NXOS image repo, etc.

**####### role extract ######**

- name: Run Config creation script with param’s  
ansible.builtin.script: /automation/network/cat-net-nutan-nexus-01/create\_new\_config\_file.py  
-u “{{n9k\_item.value.user}}”  
-p “{{n9k\_item.value.passwd}}”  
-sid “{{n9k\_item.value.switchid}}”  
-pid “{{n9k\_item.value.pairedswitchid}}”  
-ma “{{n9k\_item.value.mgmt}}”  
-mr “{{n9k\_item.value.mgmtroute}}”  
-kd “{{n9k\_item.value.keepalivedest}}”  
-ks “{{n9k\_item.value.keepalivesource}}”  
-109a “{{n9k\_item.value.vlan109address}}”  
-109h “{{n9k\_item.value.vlan109hsrpaddress}}”  
-109p “{{n9k\_item.value.vlan109hsrppriority}}”  
-111h “{{n9k\_item.value.vlan111hsrpaddress}}”  
-111a “{{n9k\_item.value.vlan111address}}”  
-111h “{{n9k\_item.value.vlan111hsrpaddress}}”  
-111p “{{n9k\_item.value.vlan111hsrppriority}}”  
-113a “{{n9k\_item.value.vlan113address}}”  
-113h “{{n9k\_item.value.vlan113hsrpaddress}}”  
-113p “{{n9k\_item.value.vlan113hsrppriority}}”  
-114a “{{n9k\_item.value.vlan114address}}”  
-114h “{{n9k\_item.value.vlan114hsrpaddress}}”  
-114p “{{n9k\_item.value.vlan114hsrppriority}}”  
-114d “{{n9k\_item.value.vlan114dhcphelper}}”  
-s “{{n9k\_item.value.serial}}”  
-e1\_7 “{{n9k\_item.value.interfaceEth1\_7}}”  
-v “{{n9k\_item.value.vic}}”  
-d “{{n9k\_item.value.defaultroute}}”  
-b “{{n9k\_item.value.metsi\_build\_ip}}”  
-c “{{n9k\_item.value.customerid}}”  
-e1\_7h “{{n9k\_item.value.interfaceEth1\_7hsrpaddress}}”  
-e1\_7p “{{n9k\_item.value.interfaceEth1\_7hsrppriority}}”  
–mpc  
args:  
executable: python3  
register: config\_creation\_out  
changed\_when: ‘“written successfully” in config\_creation\_out.stdout’  
loop: “{{config\_script\_arguments|dict2items}}”  
loop\_control:  
loop\_var: n9k\_item  
when:
- state == ‘present’
- config\_script\_arguments is defined

# delegate\_to: localhost

delegate\_to: 10.22.148.12

**####### roles extract ######**

Issue from AWX  
When I try to execute this from AWX with an EE it fails, output below.  
**ansible-builtin.script does not have a parameter for remote\_src**

**########### AWX output ######################**  
{  
“msg”: “Could not find or access ‘/automation/network/cat-net-nutan-nexus-01/create\_new\_config\_file.py’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote\_src option”,  
“exception”: “Traceback (most recent call last):\n File "/home/runner/.local/lib/python3.8/site-packages/ansible/plugins/action/script.py", line 86, in run\n source = self.\_loader.get\_real\_file(self.\_find\_needle(‘files’, source), decrypt=self.\_task.args.get(‘decrypt’, True))\n File "/home/runner/.local/lib/python3.8/site-packages/ansible/plugins/action/ **init**.py", line 1417, in \_find\_needle\n return self.\_loader.path\_dwim\_relative\_stack(path\_stack, dirname, needle)\n File "/home/runner/.local/lib/python3.8/site-packages/ansible/parsing/dataloader.py", line 341, in path\_dwim\_relative\_stack\n raise AnsibleFileNotFound(file\_name=source, paths=[to\_native(p) for p in search])\nansible.errors.AnsibleFileNotFound: Could not find or access ‘/automation/network/cat-net-nutan-nexus-01/create\_new\_config\_file.py’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote\_src option\n”,  
“\_ansible\_no\_log”: null,  
“changed”: false,  
“changed\_when\_result”: “The conditional check ‘"written successfully" in config\_creation\_out.stdout’ failed. The error was: error while evaluating conditional ("written successfully" in config\_creation\_out.stdout): ‘dict object’ has no attribute ‘stdout’”,  
“n9k\_item”: {  
“key”: “script\_argument\_set\_2”,  
“value”: {  
“user”: “admin”,  
“passwd”: “removed”,  
“customerid”: “awx-platform-01”,  
“switchid”: “02”,  
“pairedswitchid”: “01”,  
“mgmt”: “192.168.160.33/24”,  
“mgmtroute”: “192.168.160.1”,  
“keepalivedest”: “192.168.160.32”,  
“keepalivesource”: “192.168.160.33”,  
“vlan109address”: “192.168.161.8/24”,  
“vlan109hsrpaddress”: “192.168.161.5”,  
“vlan109hsrppriority”: 90,  
“vlan111address”: “192.168.162.4/24”,  
“vlan111hsrpaddress”: “192.168.162.1”,  
“vlan111hsrppriority”: 110,  
“vlan113address”: “192.168.163.4/24”,  
“vlan113hsrpaddress”: “192.168.163.1”,  
“vlan113hsrppriority”: 90,  
“vlan114address”: “192.168.164.4/24”,  
“vlan114hsrpaddress”: “192.168.164.1”,  
“vlan114hsrppriority”: 110,  
“vlan114dhcphelper”: “10.22.162.64”,  
“serial”: " removed “,  
“defaultroute”: “192.168.161.1”,  
“interfaceEth1\_7”: “192.168.161.8/24”,  
“interfaceEth1\_7hsrpaddress”: “192.168.161.5”,  
“interfaceEth1\_7hsrppriority”: 90,  
“vic”: 3,  
“metsi\_build\_ip”: “10.22.148.12”  
}  
},  
“ansible\_loop\_var”: “n9k\_item”,  
“\_ansible\_item\_label”: {  
“key”: “script\_argument\_set\_2”,  
“value”: {  
“user”: “admin”,  
“passwd”: " removed”,  
“customerid”: “awx-platform-01”,  
“switchid”: “02”,  
“pairedswitchid”: “01”,  
“mgmt”: “192.168.160.33/24”,  
“mgmtroute”: “192.168.160.1”,  
“keepalivedest”: “192.168.160.32”,  
“keepalivesource”: “192.168.160.33”,  
“vlan109address”: “192.168.161.8/24”,  
“vlan109hsrpaddress”: “192.168.161.5”,  
“vlan109hsrppriority”: 90,  
“vlan111address”: “192.168.162.4/24”,  
“vlan111hsrpaddress”: “192.168.162.1”,  
“vlan111hsrppriority”: 110,  
“vlan113address”: “192.168.163.4/24”,  
“vlan113hsrpaddress”: “192.168.163.1”,  
“vlan113hsrppriority”: 90,  
“vlan114address”: “192.168.164.4/24”,  
“vlan114hsrpaddress”: “192.168.164.1”,  
“vlan114hsrppriority”: 110,  
“vlan114dhcphelper”: “10.22.162.64”,  
“serial”: " removed",  
“defaultroute”: “192.168.161.1”,  
“interfaceEth1\_7”: “192.168.161.8/24”,  
“interfaceEth1\_7hsrpaddress”: “192.168.161.5”,  
“interfaceEth1\_7hsrppriority”: 90,  
“vic”: 3,  
“metsi\_build\_ip”: “10.22.148.12”  
}  
},  
“\_ansible\_delegated\_vars”: {  
“ansible\_host”: “10.22.148.12”,  
“ansible\_port”: null,  
“ansible\_user”: “root”  
}  
}

**########### AWX output ######################**

How can I get this playbook/role/request to be executed on the remote server sucessfully?

Any ideas or fixes would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![kdelee](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kdelee/32/193_2.png) [@kdelee](https://forum.ansible.com/u/kdelee)\
**Post date:** [October 27, 2023, 12:39pm UTC](https://forum.ansible.com/t/how-to-execute-a-script-from-awx-via-ee-on-a-remote-server/38552/2 "2023-10-27T12:39:04Z")

</div>

The current docs say

- The local script at path will be transferred to the remote node and then executed.

You might try including the script in your git project, and then refer to it with a relative path from the playbook. For ease, I would put the file right next to the playbook. There is a special variable “playbook\_dir” [https://docs.ansible.com/ansible/latest/reference\_appendices/special\_variables.html#term-playbook\_dir](https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html#term-playbook_dir).

Sounds like module takes care of transferring the script
