cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
431
Views
0
Helpful
2
Replies

Ansible - change IO Helper of VLAN Interfaces

Netmart
Level 1
Level 1

Hello

I tried the following Ansible playbook, the goal is to change the ip helper address of an existing vlan interface.

And I am receiving the following error:

 

TASK [Changing IP Helper Address] **************************************************************************************************************

fatal: [switch.com]: FAILED! => {"changed": false, "module_stderr": "interface \"vlan10\"\r\ninterface \"vlan10\"\r\n          ^\r\n% Invalid input detected at '^' marker.\r\n\r\nmtlab-c4500(config)#", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}

PLAY RECAP **************************************************************************************************************

switch.com: ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=

 

Playbook:

---
- name: VLAN IP Helper Address on Cisco IOS XE
  hosts: iosxe1
  vars_files:
         - /home/wolfm/Ansible/vault_password.yml
  vars:
      ansible_become_pass: "{{ vault_sudo_password }}"
      ansible_python_interpreter: /usr/bin/python3
      vlan_interface_show: Vlan10
      vlan_interface_config: vlan10
     
   
  tasks:
     - name: show run | sec Vlan - Prior to Change
       ios_command:
          commands:
              - show run | sec "{{vlan_interface_show}}"

       become: true
       register: output1



 
     - name: "Changing IP Helper Address"
       ios_config:
          commands:
              - no ip helper-address 10.0.0.1
              - ip helper-address 10.0.0.2
          parents: interface "{{vlan_interface_config}}"
          #parents: interface vlan10

       become: true
       register: output2


 
     - name: show run | sec Vlan - Post to Change
       ios_command:
          commands:
              - show run | sec "{{vlan_interface_show}}"

       become: true
       register: output3


       
     - name: show run | sec Vlan - Prior to Change
       debug:
          var: output1


     - name: show run | sec Vlan - Post to Change
       debug:
          var: output3

 

 

 

2 Replies 2

balaji.bandi
Hall of Fame
Hall of Fame

If you looking to change the VLAN 10  IP helper address : i use below code that works for me :

https://pynet.twb-tech.com/blog/using-ansible-to-configure-DHCP-helpers.html

or you looking validate before changing ?

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

M02@rt37
VIP
VIP

Hello @Netmart 

Instead of using the parents parameter with the interface keyword, you should directly specify the interface in the command itself.

- name: "Changing IP Helper Address"
ios_config:
lines:
- no ip helper-address 10.0.0.1
- ip helper-address 10.0.0.2
parents: interface "{{vlan_interface_config}}"
become: true
register: output2

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.