W3cubDocs

/Ansible

cisco.nxos.nxos_hsrp_interfaces – HSRP interfaces resource module

Note

This plugin is part of the cisco.nxos collection (version 2.7.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.nxos.

To use it in a playbook, specify: cisco.nxos.nxos_hsrp_interfaces.

New in version 1.0.0: of cisco.nxos

Synopsis

  • Manages Hot Standby Router Protocol (HSRP) interface attributes.

Note

This module has a corresponding action plugin.

Parameters

Parameter Choices/Defaults Comments
config
list / elements=dictionary
The provided configuration
bfd
string
    Choices:
  • enable
  • disable
Enable/Disable HSRP Bidirectional Forwarding Detection (BFD) on the interface.
name
string
The name of the interface.
running_config
string
This option is used only with state parsed.
The value of this option should be the output received from the NX-OS device by executing the command show running-config | section '^interface'.
The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the parsed key within the result.
state
string
    Choices:
  • merged
  • replaced
  • overridden
  • deleted
  • gathered
  • rendered
  • parsed
The state the configuration should be left in

Notes

Note

  • Tested against NX-OS 7.0(3)I5(1).
  • Feature bfd should be enabled for this module.
  • Unsupported for Cisco MDS

Examples

# Using deleted

- name: Configure hsrp attributes on interfaces
  cisco.nxos.nxos_hsrp_interfaces:
    config:
    - name: Ethernet1/1
    - name: Ethernet1/2
    operation: deleted


# Using merged

- name: Configure hsrp attributes on interfaces
  cisco.nxos.nxos_hsrp_interfaces:
    config:
    - name: Ethernet1/1
      bfd: enable
    - name: Ethernet1/2
      bfd: disable
    operation: merged


# Using overridden

- name: Configure hsrp attributes on interfaces
  cisco.nxos.nxos_hsrp_interfaces:
    config:
    - name: Ethernet1/1
      bfd: enable
    - name: Ethernet1/2
      bfd: disable
    operation: overridden


# Using replaced

- name: Configure hsrp attributes on interfaces
  cisco.nxos.nxos_hsrp_interfaces:
    config:
    - name: Ethernet1/1
      bfd: enable
    - name: Ethernet1/2
      bfd: disable
    operation: replaced

# Using rendered

- name: Use rendered state to convert task input to device specific commands
  cisco.nxos.nxos_hsrp_interfaces:
    config:
    - name: Ethernet1/800
      bfd: enable
    - name: Ethernet1/801
      bfd: enable
    state: rendered

# Task Output (redacted)
# -----------------------

# rendered:
#   - "interface Ethernet1/800"
#   - "hsrp bfd"
#   - "interface Ethernet1/801"
#   - "hsrp bfd"

# Using parsed

# parsed.cfg
# ------------
# interface Ethernet1/800
#   no switchport
#   hsrp bfd
# interface Ethernet1/801
#   no switchport
#   hsrp bfd

- name: Use parsed state to convert externally supplied config to structured format
  cisco.nxos.nxos_hsrp_interfaces:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed

# Task output (redacted)
# -----------------------

# parsed:
#   - name: Ethernet1/800
#     bfd: enable
#   - name: Ethernet1/801
#     bfd: enable

# Using gathered

# Existing device config state
# -------------------------------

# interface Ethernet1/1
#   no switchport
#   hsrp bfd
# interface Ethernet1/2
#   no switchport
#   hsrp bfd
# interface Ethernet1/3
#   no switchport

- name: Gather hsrp_interfaces facts from the device using nxos_hsrp_interfaces
  cisco.nxos.nxos_hsrp_interfaces:
    state: gathered

# Task output (redacted)
# -----------------------

# gathered:
#   - name: Ethernet1/1
#     bfd: enable
#   - name: Ethernet1/2
#     bfd: enable

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
after
list / elements=string
when changed
The resulting configuration model invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
before
list / elements=string
always
The configuration prior to the model invocation.

Sample:
The configuration returned will always be in the same format of the parameters above.
commands
list / elements=string
always
The set of commands pushed to the remote device.

Sample:
['interface Ethernet1/1', 'hsrp bfd']


Authors

  • Chris Van Heuveln (@chrisvanheuveln)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/cisco/nxos/nxos_hsrp_interfaces_module.html