Resource module to configure hostname.
Version added: 2.7.0
- This module configures and manages the attributes of hostname on Cisco IOSXR platforms.
Note
- Tested against Cisco Iosxr 7.0.2
- This module works with connection
network_cli
.
# Using state: merged
# Before state:
# -------------
# RP/0/RP0/CPU0:ios#show running-config hostname
# Thu Jan 20 19:48:56.011 UTC
# hostname ios
# Merged play:
# ------------
- name: Apply the provided configuration
cisco.iosxr.iosxr_hostname:
config:
hostname: Router1
state: merged
# Commands Fired:
# ---------------
# "commands": [
# "hostname Router1",
# ],
# After state:
# ------------
# RP/0/0/CPU0:Router1#show running-config hostname
# Thu Jan 20 19:48:56.011 UTC
# hostname Router1
# Using state: deleted
# Before state:
# -------------
# RP/0/0/CPU0:Router1#show running-config hostname
# Thu Jan 20 19:48:56.011 UTC
# hostname Router1
# Deleted play:
# -------------
- name: Remove all existing configuration
cisco.iosxr.iosxr_hostname:
state: deleted
# Commands Fired:
# ---------------
# "commands": [
# "no hostname Router1",
# ],
# After state:
# ------------
# RP/0/RP0/CPU0:ios#show running-config hostname
# Thu Jan 20 19:55:12.971 UTC
# hostname ios
# Using state: overridden
# Before state:
# -------------
# RP/0/0/CPU0:ios#show running-config hostname
# hostname ios
# Overridden play:
# ----------------
- name: Override commands with provided configuration
cisco.iosxr.iosxr_hostname:
config:
hostname: RouterTest
state: overridden
# Commands Fired:
# ---------------
# "commands": [
# "hostname RouterTest",
# ],
# After state:
# ------------
# RP/0/RP0/CPU0:RouterTest#show running-config hostname
# Thu Jan 20 19:48:56.011 UTC
# hostname RouterTest
# Using state: replaced
# Before state:
# -------------
# RP/0/RP0/CPU0:RouterTest#show running-config hostname
# Thu Jan 20 19:48:56.011 UTC
# hostname RouterTest
# Replaced play:
# --------------
- name: Replace commands with provided configuration
cisco.iosxr.iosxr_hostname:
config:
hostname: RouterTest
state: replaced
# Commands Fired:
# ---------------
# "commands": [],
# After state:
# ------------
# RP/0/0/CPU0:RouterTest#show running-config hostname
# hostname RouterTest
# Using state: gathered
# Before state:
# -------------
# RP/0/RP0/CPU0:RouterTest#show running-config hostname
# Thu Jan 20 19:48:56.011 UTC
# hostname RouterTest
# Gathered play:
# --------------
- name: Gather listed hostname config
cisco.iosxr.iosxr_hostname:
state: gathered
# Module Execution Result:
# ------------------------
# "gathered": {
# "hostname": "RouterTest"
# },
# Using state: rendered
# Rendered play:
# --------------
- name: Render the commands for provided configuration
cisco.iosxr.iosxr_hostname:
config:
hostname: RouterTest
state: rendered
# Module Execution Result:
# ------------------------
# "rendered": [
# "hostname RouterTest",
# ]
# Using state: parsed
# File: parsed.cfg
# ----------------
# hostname RouterTest
# Parsed play:
# ------------
- name: Parse the provided configuration with the existing running configuration
cisco.iosxr.iosxr_hostname:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Module Execution Result:
# ------------------------
# "parsed": {
# "hostname": "RouterTest"
# }
Common return values are documented here, the following are the fields unique to this module:
- Ashwini Mhatre (@amhatre)