Ansible – net_put error

Unknown and weird error faced while utilizing ansible’s network module “net_put” to transfer image file from local to a remote network device

The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 147, in run
    res = self._execute()
  File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 660, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/net_put.py", line 131, in run
    result['changed'] = changed
UnboundLocalError: local variable 'changed' referenced before assignment
fatal: [ios]: FAILED! => {
  "msg": "Unexpected failure during module execution.",
  "stdout": ""
}

Seriously….. who understands this error?!

Solution

As the error is not significant, I wouldn’t want to assume my scenario will fix all so for my case, I scraped through the ansible core’s python script file and found the problem which gives the error. Apparently python scp is not installed and to fix it, a simple install command will do

pip3 install scp

For those using ansible AWX, interim solution is to perform “docker exec -it < awx-task id > /bin/bash” and execute the above command but my recommended long term solution is to recreate a docker image after installing scp and store it in local docker.

This will prevent the same issue after docker vm reboots

Design a site like this with WordPress.com
Get started