cisco.ios.ios_hsrp_interfaces module – Resource module to configure HSRP on interfaces.
Note
This module is part of the cisco.ios collection (version 11.0.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install cisco.ios
.
To use it in a playbook, specify: cisco.ios.ios_hsrp_interfaces
.
New in cisco.ios 10.1.0
Synopsis
This module provides declarative management of HSRP configuration on interface for Cisco IOS devices.
Parameters
Parameter |
Comments |
---|---|
A list of HSP configuration options to add to interface |
|
Enable HSRP BFD Choices:
|
|
HSRP initialization delay |
|
Delay at least this long |
|
Delay after reload |
|
Name of HSRP group to follow |
|
Refresh MAC cache on switch by periodically sending packet from virtual mac address |
|
Full name of the interface excluding any logical unit number, i.e. GigabitEthernet0/1. |
|
Redirect configuration |
|
Redirect advertisement messages (standby redirect advertisement authentication md5) |
|
Authentication configuration |
|
Set encryption 0 (unencrypted/default) or 7 (hidden) |
|
Set key chain |
|
Set key string Choices:
|
|
Password text valid for plain text and and key-string |
|
Set timeout |
|
Adjust redirect timers |
|
Passive router advertisement interval in seconds |
|
Passive router holddown interval in seconds |
|
Group number and group options for standby (HSRP) |
|
Authentication configuration |
|
Redirect advertisement messages (standby redirect advertisement authentication md5) |
|
Set encryption 0 (unencrypted/default) or 7 (hidden) |
|
Set key chain |
|
Set key string Choices:
|
|
Password text valid for plain text and and key-string |
|
Password text valid for plain text |
|
Password text valid for plain text and and key-string |
|
Set timeout |
|
Enable HSRP BFD |
|
Redundancy name string |
|
Group number |
|
Enable HSRP IPv4 and set the virtual IP address |
|
Make this IP address a secondary virtual IP address Choices:
|
|
Virtual IP address |
|
Enable HSRP IPv6 and set the IP address |
|
Obtain address using autoconfiguration Choices:
|
|
X:x:X:x::X IPv6 link-local address |
|
X:x:X:x::X/<0-128> IPv6 prefix |
|
Virtual MAC address |
|
Overthrow lower priority Active routers |
|
Wait before preempting Choices:
|
|
Enables preempt, drives the lone `standby <grp_no> preempt` command Choices:
|
|
Delay at least this long |
|
Delay after reload |
|
Wait for IP redundancy clients |
|
Priority level |
|
Overthrow lower priority Active routers |
|
Hello interval in seconds |
|
Hold time in seconds |
|
Specify hello interval in milliseconds |
|
<15-999> Hello interval in milliseconds |
|
<60-3000> Hold time in milliseconds |
|
Priority tracking |
|
Priority decrement |
|
Shutdown Group Choices:
|
|
Track object number |
|
HSRP uses interface’s burned in address (does not work with mac address) |
|
Scope interface option |
|
Use-bia applies to all groups on this interface or sub-interface Choices:
|
|
HSRP version |
|
This option is used only with state parsed. The value of this option should be the output received from the IOS device by executing the command show running-config | section ^interface. The state parsed reads the configuration from |
|
The state the configuration should be left in The states rendered, gathered and parsed does not perform any change on the device. The state rendered will transform the configuration in The state gathered will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the gathered key within the result. The state parsed reads the configuration from Choices:
|
Notes
Note
Tested against Cisco IOSXE Version 17.16.
This module works with connection
network_cli
. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.htmlThe module examples uses callback plugin (callback_result_format=yaml) to generate task output in yaml format.
Examples
# Using merged
# Before state:
# -------------
#
# Router#show running-config | section ^interface
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# ip ospf network broadcast
# ip ospf resync-timeout 10
# ip ospf dead-interval 5
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet4
# no ip address
# shutdown
# negotiation auto
- name: Merge provided configuration with device configuration
cisco.ios.ios_hsrp_interfaces:
config:
- name: GigabitEthernet3
standby_groups:
- group_no: 22
ip:
- virtual_ip: 10.0.0.1
secondary: true
- name: GigabitEthernet4
standby_groups:
- group_no: 0
priority: 5
state: merged
# Task Output
# -----------
#
# before:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# - name: GigabitEthernet4
# - name: Loopback999
# - name: Loopback888
# commands:
# - interface GigabitEthernet3
# - standby 22 ip 10.0.0.1 secondary
# - interface GigabitEthernet4
# - standby 0 priority 5
# after:
# name: GigabitEthernet1
# name: GigabitEthernet2
# name: GigabitEthernet3
# standby_groups:
# - group_no: 22
# ip:
# - virtual_ip: 192.168.0.2
# secondary: True
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 5
# - name: Loopback999
# - name: Loopback888
# After state:
# ------------
#
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# standby 22 ip 10.0.0.1 secondary
# no negotiation auto
# interface GigabitEthernet4
# no ip address
# standby 0 priority 5
# shutdown
# negotiation auto
# Using replaced
# Before state:
# -------------
#
# Router#show running-config | section ^interface
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# standby 22 ip 10.0.0.1 secondary
# no negotiation auto
# interface GigabitEthernet4
# no ip address
# standby 0 priority 5
# shutdown
# negotiation auto
- name: Replaces device configuration of listed interfaces with provided configuration
cisco.ios.ios_hsrp_interfaces:
config:
- name: GigabitEthernet3
standby_groups:
- group_no: 22
ip:
- virtual_ip: 10.0.0.1
secondary: true
- name: GigabitEthernet4
standby_groups:
- group_no: 0
priority: 6
state: replaced
# Task Output
# -----------
#
# before:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# standby_groups:
# - group_no: 22
# ip:
# - virtual_ip: 192.168.0.2
# secondary: True
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 6
# - name: Loopback999
# - name: Loopback888
# commands:
# - interface GigabitEthernet3
# - standby 22 ip 10.0.0.1 secondary
# - interface GigabitEthernet4
# - standby 0 priority 5
# after:
# name: GigabitEthernet1
# name: GigabitEthernet2
# name: GigabitEthernet3
# standby_groups:
# - group_no: 22
# ip:
# - virtual_ip: 192.168.0.2
# secondary: True
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 6
# - name: Loopback999
# - name: Loopback888
# After state:
# ------------
#
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# ip ospf network broadcast
# ip ospf resync-timeout 10
# ip ospf dead-interval 5
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# standby 22 ip 10.0.0.1 secondary
# speed 1000
# no negotiation auto
# interface GigabitEthernet4
# description Auto_Cable_Testing_Ansible
# no ip address
# standby 0 priority 6
# shutdown
# negotiation auto
# Using overridden
# Before state:
# -------------
#
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# ip ospf network broadcast
# ip ospf resync-timeout 10
# ip ospf dead-interval 5
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# standby 22 ip 10.0.0.1 secondary
# speed 1000
# no negotiation auto
# interface GigabitEthernet4
# description Auto_Cable_Testing_Ansible
# no ip address
# standby 0 priority 6
# shutdown
# negotiation auto
- name: Override device configuration of all interfaces with provided configuration
cisco.ios.ios_hsrp_interfaces:
config:
- name: GigabitEthernet4
standby_groups:
- group_no: 0
priority: 10
state: overridden
# Task Output
# -----------
# before:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# standby_groups:
# - group_no: 22
# ip:
# - virtual_ip: 192.168.0.2
# secondary: True
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 6
# - name: Loopback999
# - name: Loopback888
# commands:
# - interface GigabitEthernet3
# - no standby 22 ip 10.0.0.1 secondary
# - interface GigabitEthernet4
# - no standby 0 priority 6
# - standby 0 priority 10
# after:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 10
# - name: Loopback999
# - name: Loopback888
# After state:
# ------------
#
# router-ios#show running-config | section ^interface
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# ip ospf network broadcast
# ip ospf resync-timeout 10
# ip ospf dead-interval 5
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet4
# description Auto_Cable_Testing_Ansible
# no ip address
# standby 0 priority 10
# shutdown
# negotiation auto
# Using deleted
# Before state:
# -------------
#
# router-ios#show running-config | section ^interface
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# ip ospf network broadcast
# ip ospf resync-timeout 10
# ip ospf dead-interval 5
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet4
# description Auto_Cable_Testing_Ansible
# no ip address
# standby 0 priority 10
# shutdown
# negotiation auto
- name: "Delete attributes of given interfaces (NOTE: This won't delete the interfaces)"
cisco.ios.ios_hsrp_interfaces:
config:
- name: GigabitEthernet4
state: deleted
# Task Output
# -----------
#
# before:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 10
# - name: Loopback999
# - name: Loopback888
# commands:
# - interface GigabitEthernet4
# - no standby 0 priority 10
# after:
# name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# - name: GigabitEthernet4
# - name: Loopback999
# - name: Loopback888
# After state:
# -------------
#
# router-ios#show running-config | section ^interface
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# ip ospf network broadcast
# ip ospf resync-timeout 10
# ip ospf dead-interval 5
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet4
# description Auto_Cable_Testing_Ansible
# no ip address
# shutdown
# negotiation auto
# Using deleted without config passed, only interface's configuration will be negated
# Before state:
# -------------
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# standby 22 ip 10.0.0.1 secondary
# no negotiation auto
# interface GigabitEthernet4
# no ip address
# standby 0 priority 5
# shutdown
# negotiation auto
- name: "Delete HSRP config of all interfaces"
cisco.ios.ios_hsrp_interfaces:
state: deleted
# Task Output
# -----------
#
# before:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# standby_groups:
# - group_no: 22
# ip:
# - virtual_ip: 192.168.0.2
# secondary: True
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 5
# - name: Loopback999
# - name: Loopback888
# commands:
# - interface GigabitEthernet3
# - no standby 22 ip 192.168.0.2 secondary
# - interface GigabitEthernet4
# - no standby 0 priority 5
# after:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# - name: GigabitEthernet3.100
# - name: GigabitEthernet4
# - name: Loopback999
# After state:
# -------------
#
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# ip ospf network broadcast
# ip ospf resync-timeout 10
# ip ospf dead-interval 5
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet4
# description Auto_Cable_Testing_Ansible
# no ip address
# shutdown
# negotiation auto
# Using gathered
# Before state:
# -------------
# interface Loopback888
# no ip address
# interface Loopback999
# no ip address
# interface GigabitEthernet1
# description Management interface do not change
# ip address dhcp
# negotiation auto
# interface GigabitEthernet2
# no ip address
# speed 1000
# no negotiation auto
# interface GigabitEthernet3
# no ip address
# speed 1000
# standby 22 ip 10.0.0.1 secondary
# no negotiation auto
# interface GigabitEthernet4
# no ip address
# standby 0 priority 5
# shutdown
# negotiation auto
- name: Gather facts for hsrp interfaces
cisco.ios.ios_hsrp_interfaces:
state: gathered
# Task Output
# -----------
#
# gathered:
# - name: GigabitEthernet1
# - name: GigabitEthernet2
# - name: GigabitEthernet3
# standby_groups:
# - group_no: 22
# ip:
# - virtual_ip: 192.168.0.2
# secondary: True
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 5
# - name: Loopback999
# - name: Loopback888
# Using rendered
- name: Render the commands for provided configuration
cisco.ios.ios_hsrp_interfaces:
config:
- name: GigabitEthernet3
standby_groups:
- group_no: 22
ip:
- virtual_ip: 192.168.0.2
secondary: true
- name: GigabitEthernet4
standby_groups:
- group_no: 0
priority: 5
state: rendered
# Task Output
# -----------
#
# rendered:
# - interface GigabitEthernet3
# - "standby 22 ip 10.0.0.1 secondary
# - interface GigabitEthernet4
# - standby 0 priority 5
# Using parsed
# File: parsed.cfg
# ----------------
#
# interface GigabitEthernet3
# standby 22 ip 10.0.0.1 secondary
# interface GigabitEthernet4
# standby 0 priority 5
# - name: Parse the provided configuration
# cisco.ios.ios_hsrp_interfaces:
# running_config: "{{ lookup('file', 'parsed.cfg') }}"
# state: parsed
# Task Output
# -----------
#
# parsed:
# - name: GigabitEthernet3
# standby_groups:
# - group_no: 22
# ip:
# - virtual_ip: 192.168.0.2
# secondary: True
# - name: GigabitEthernet4
# standby_groups:
# - group_no: 0
# priority: 5
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The resulting configuration after module execution. Returned: when changed Sample: |
|
The configuration prior to the module execution. Returned: when state is Sample: |
|
The set of commands pushed to the remote device. Returned: when state is Sample: |
|
Facts about the network resource gathered from the remote device as structured data. Returned: when state is Sample: |
|
The device native config provided in running_config option parsed into structured data as per module argspec. Returned: when state is Sample: |
|
The provided configuration in the task rendered in device-native format (offline). Returned: when state is Sample: |