ENCOUNTERING MODULE FAILURE Error while using IOS_template module

75 views
Skip to first unread message

sgam...@criterionnetworks.com

unread,
Jan 6, 2017, 9:21:49 AM1/6/17
to Ansible Project, Naresh Kumar
Hello,

      I am writing simple playbook to add configuration in Cisco 2800 router using jinja2 templates,Where I am able to generate Configuration file using Template module.But after generating the configuration file i.e. shubham.J2  i am getting the following  error while pushing configurations to device.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: cnlabs(config)#
fatal: [192.168.3.65]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_HV_5qu/ansible_module_ios_template.py\", line 174, in <module>\n    main()\n  File \"/tmp/ansible_HV_5qu/ansible_module_ios_template.py\", line 165, in main\n    response = module.config(commands)\n  File \"/tmp/ansible_HV_5qu/ansible_modlib.zip/ansible/module_utils/netcfg.py\", line 54, in __call__\n  File \"/tmp/ansible_HV_5qu/ansible_modlib.zip/ansible/module_utils/ios.py\", line 194, in configure\n  File \"/tmp/ansible_HV_5qu/ansible_modlib.zip/ansible/module_utils/shell.py\", line 250, in execute\nansible.module_utils.network.NetworkError: matched error in response: configure terminal\r\n                     ^\r\n% Invalid input detected at '^' marker.\r\n\r\ncnlabs(config)#\n", "module_stdout": "", "msg": "MODULE FAILURE"}

 my configuration file looks like:(shubham.j2)

configure terminal
interface fastEthernet 0/0
ip address 1.1.1.1 255.255.255.0
no shutdown
exit

  Using this configuration file I am trying to assign the above mentioned IP address to Fa 0/0 interface of my cisco device. And I am using ios_template module in my playbook to push configurations in to Device.Can anyone help me to solve this error.

Peter Sprygada

unread,
Jan 6, 2017, 2:15:36 PM1/6/17
to ansible...@googlegroups.com, Naresh Kumar
template files need to be structured as config files.  shubham.j2 should look like this:

interface FastEthernet0/0
 ip address 1.1.1.1 255.255.255.0
 no shutdown

With indents... no need to add configure terminal as the module will handle that for you

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5063a923-be72-4af7-852c-7eb67bc360ff%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

sgam...@criterionnetworks.com

unread,
Jan 8, 2017, 4:45:24 AM1/8/17
to Ansible Project, nar...@criterionnetworks.com
Thank you so much Peter for helping me in this issue..As you mentioned in previous post i made the changes in my script and everything is working....Thanks
Reply all
Reply to author
Forward
0 new messages