An exception occurred during task execution in ansible playbook

441 views
Skip to first unread message

Samya Ghosh

unread,
Aug 11, 2017, 7:44:10 AM8/11/17
to Ansible Development
Dear all, 

I am geting an error during my playbook running . 

i am using ntc-ansible and I want to send command from a text file in a Network for routing configuration 

code is like this with ntc ansible 


---

- name: Inbound command modification
  hosts: ciscors
  strategy: debug
  connection: local
  gather_facts: no
  
  
  vars:
    cli:  
        ciscoios: 'ciscors'
        ciscoiosssh: 'ciscors_ssh'
        localfile: 'C:/Users/sg05477/GNS3/images/IOS.bin'
        remotefile: 'c7200-advipservicesk9-mz.152-4.S5.bin'
        
        
        
  tasks:
   -  name: Send commands from file
      ntc_config_command:
        connection: ssh
        platform: cisco_ios        
        commands_file: "send_commands.txt"        
        host: "{{ inventory_hostname }}"
        username: "{{ user }}"
        password: "{{ pass }}"
        secret: "{{ secret }}" 
      
        
   - debug: var=hostvars[inventory_hostname]
   #- debug: var=hostvars[user]
   
   #- debug: var=result.response
   #- debug: var=result.response.stdout      
      



During running playbook with ansible , i getting error like 


PLAY [Inbound command modification] ************************************************************************************************************************************************************************

TASK [Send commands from file] *****************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnboundLocalError: local variable 'output' referenced before assignment
fatal: [192.168.1.11]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_bJ4FjY/ansible_module_ntc_config_command.py\", line 256, in <module>\n    main()\n  File \"/tmp/ansible_bJ4FjY/ansible_module_ntc_config_command.py\", line 244, in main\n    if (error_params(platform, output)):\nUnboundLocalError: local variable 'output' referenced before assignment\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}



Anyone have some solution , how i correct this error. 

it will be very helpful. 


Thanks 

Samya Ghosh 

Adrian Likins

unread,
Aug 11, 2017, 11:41:43 AM8/11/17
to Samya Ghosh, Ansible Development
That looks like a bug in a module thats not in ansible/ansible but in https://github.com/networktocode/ntc-ansible/blob/master/library/ntc_config_command.py#L244
(More specifically, like the error references, the 'output' var there isn't defined there. Looks like either a indent/scope issue, or just a missing
default for 'output')

Should file an issue for their ntc_config_command module in their issue tracker at their github repo: https://github.com/networktocode/ntc-ansible/issues

--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages