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.