cisco.ios.ios_service module – Resource module to configure service.
Note
This module is part of the cisco.ios collection (version 5.3.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_service
.
New in cisco.ios 4.6.0
Synopsis
This module configures and manages service attributes on IOS platforms
Parameters
Parameter |
Comments |
---|---|
A dictionnary of service configuration |
|
Cisco call-home service Choices:
|
|
Compress the nvram configuration file Choices:
|
|
TFTP load config files Choices:
|
|
Control aging of interface counters by setting the maximum counter aging threshold Default: |
|
Enable DHCP server and relay agent Choices:
|
|
Disable IP particle-based fast fragmentation Choices:
|
|
Enable exec callback Choices:
|
|
Delay EXEC startup on noisy lines Choices:
|
|
Hide destination addresses in telnet command Choices:
|
|
Enable/Disable Internal commands Choices:
|
|
enable line number banner for each exec Choices:
|
|
log backtrace Choices:
|
|
Enable syslog msgs for hidden/internal commands Choices:
|
|
Enable Nagle’s congestion control algorithm Choices:
|
|
Allow old scripts to operate with slip/ppp Choices:
|
|
Enable PAD commands Choices:
|
|
Enable PAD over CMNS connections Choices:
|
|
Accept XOT to PAD connections Choices:
|
|
Allow outgoing PAD over XOT connections Choices:
|
|
Encrypt system passwords Choices:
|
|
Password recovery Choices:
|
|
Enable private config file encryption Choices:
|
|
Enable mode specific prompt Choices:
|
|
Log significant VTY-Async events Choices:
|
|
scripting Choices:
|
|
Stamp logger messages with a sequence number Choices:
|
|
slave-coredump Choices:
|
|
Enable log capability of slave IPs Choices:
|
|
Generate keepalives on idle incoming network connections Choices:
|
|
Generate keepalives on idle outgoing network connections Choices:
|
|
TCP and UDP small servers are servers (daemons, in Unix parlance) that run in the router which are useful for diagnostics. |
|
Enable small TCP servers (e.g., ECHO) Choices:
|
|
Set number of allowable TCP small servers 1 to 2147483647 or no-limit |
|
Set TCP window 0 when connection is idle Choices:
|
|
Timestamp debug/log messages |
|
Options for date and time timestamp |
|
Use local time zone for timestamps Choices:
|
|
Include milliseconds in timestamp Choices:
|
|
Add time zone information to timestamp Choices:
|
|
Include year in timestam Choices:
|
|
Enable timestamp for the choosen message Choices:
|
|
Timestamp log or debug messages Choices:
|
|
Timestamp with date and time or with system uptime Choices:
|
|
TCP and UDP small servers are servers (daemons, in Unix parlance) that run in the router which are useful for diagnostics. |
|
Enable small UDP servers (e.g., ECHO) Choices:
|
|
Set number of allowable TCP small servers 1 to 2147483647 or no-limit |
|
enable support for third-party transceivers Choices:
|
|
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 ^service|^no service. The state parsed reads the configuration from |
|
The state the configuration should be left in. The module have declaratively similar behavior for replaced and overridden state. Refer to examples for more details. Choices:
|
Notes
Note
Tested against Cisco IOSXE Version 16.9
This module works with connection
network_cli
. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html
Examples
# Using merged
# Before state:
# -------------
# router-ios#show running-config all | section ^service
# service slave-log
# service timestamps debug datetime msec
# service timestamps log datetime msec
# service private-config-encryption
# service prompt config
# service counters max age 0
# service dhcp
# service call-home
# service password-recovery
- name: Merge provided configuration with device configuration
cisco.ios.ios_service:
config:
tcp_keepalives_in: true
tcp_keepalives_out: true
timestamps:
- msg: debug
enable: true
timestamp: datetime
- msg: log
enable: true
timestamp: datetime
pad: false
password_encryption: true
state: merged
# Task Output
# -----------
#
# before:
# call_home: true
# counters: 0
# dhcp: true
# password_recovery: true
# private_config_encryption: true
# prompt: true
# slave_log: true
# timestamps:
# - datetime_options:
# msec: true
# msg: debug
# timestamp: datetime
# - datetime_options:
# msec: true
# msg: log
# timestamp: datetime
# commands:
# - service password-encryption
# - service tcp-keepalives-in
# - service tcp-keepalives-out
# after:
# call_home: true
# counters: 0
# dhcp: true
# password_encryption: true
# password_recovery: true
# private_config_encryption: true
# prompt: true
# slave_log: true
# tcp_keepalives_in: true
# tcp_keepalives_out: true
# timestamps:
# - datetime_options:
# msec: true
# msg: debug
# timestamp: datetime
# - datetime_options:
# msec: true
# msg: log
# timestamp: datetime
# After state:
# ------------
# router-ios#show running-config all | section ^service
# service slave-log
# service tcp-keepalives-in
# service tcp-keepalives-out
# service timestamps debug datetime msec
# service timestamps log datetime msec
# service password-encryption
# service private-config-encryption
# service prompt config
# service counters max age 0
# service dhcp
# service call-home
# service password-recovery
# Using replaced
# Before state:
# -------------
# router-ios#show running-config all | section ^service
# service slave-log
# service tcp-keepalives-in
# service tcp-keepalives-out
# service timestamps debug datetime msec
# service timestamps log datetime msec
# service password-encryption
# service private-config-encryption
# service prompt config
# service counters max age 0
# service dhcp
# service call-home
# service password-recovery
- name: Replaces device configuration of services with provided configuration
cisco.ios.ios_service:
config:
timestamps:
- msg: log
enable: true
timestamp: datetime
datetime_options:
localtime: true
msec: true
show_timezone: true
year: true
- msg: debug
enable: true
timestamp: datetime
pad: false
password_encryption: true
state: "replaced"
# Task Output
# -----------
#
# before:
# call_home: true
# counters: 0
# dhcp: true
# password_encryption: true
# password_recovery: true
# private_config_encryption: true
# prompt: true
# slave_log: true
# tcp_keepalives_in: true
# tcp_keepalives_out: true
# timestamps:
# - datetime_options:
# msec: true
# msg: debug
# timestamp: datetime
# - datetime_options:
# msec: true
# msg: log
# timestamp: datetime
# commands:
# - no service call-home
# - no service tcp-keepalives-in
# - no service tcp-keepalives-out
# - no service timestamps log
# - service timestamps log datetime msec localtime show-timezone year
# - no service timestamps debug
# - service timestamps debug datetime
# after:
# counters: 0
# dhcp: true
# password_encryption: true
# password_recovery: true
# private_config_encryption: true
# prompt: true
# slave_log: true
# timestamps:
# - msg: debug
# timestamp: datetime
# - datetime_options:
# localtime: true
# msec: true
# show_timezone: true
# year: true
# msg: log
# timestamp: datetime
# After state:
# ------------
# router-ios#show running-config all | section ^service
# service slave-log
# service timestamps debug datetime
# service timestamps log datetime msec localtime show-timezone year
# service password-encryption
# service private-config-encryption
# service prompt config
# service counters max age 0
# service dhcp
# service password-recovery
# Using Deleted
# Before state:
# -------------
# router-ios#show running-config all | section ^service
# service slave-log
# service timestamps debug datetime
# service timestamps log datetime msec localtime show-timezone year
# service password-encryption
# service private-config-encryption
# service prompt config
# service counters max age 0
# service dhcp
# service password-recovery
- name: "Delete service configuration and restore default configuration for some important service (those with a default value in module)"
cisco.ios.ios_service:
state: deleted
# Task Output
# -----------
#
# before:
# counters: 0
# dhcp: true
# password_encryption: true
# password_recovery: true
# private_config_encryption: true
# prompt: true
# slave_log: true
# timestamps:
# - msg: debug
# timestamp: datetime
# - datetime_options:
# localtime: true
# msec: true
# show_timezone: true
# year: true
# msg: log
# timestamp: datetime
# commands:
# - no service password-encryption
# - no service timestamps debug
# - no service timestamps log
# after:
# counters: 0
# dhcp: true
# password_recovery: true
# private_config_encryption: true
# prompt: true
# slave_log: true
# After state:
# ------------
#
# router-ios#show running-config all | section ^service
# service slave-log
# service private-config-encryption
# service prompt config
# service counters max age 0
# service dhcp
# service password-recovery
# Using gathered
# Before state:
# -------------
#
# router-ios#show running-config all | section ^service
# service slave-log
# service timestamps debug datetime
# service timestamps log datetime msec localtime show-timezone year
# service password-encryption
# service private-config-encryption
# service prompt config
# service counters max age 0
# service dhcp
# service password-recovery
- name: Gather facts of interfaces
cisco.ios.ios_service:
config:
state: gathered
# Task Output
# -----------
#
# gathered:
# counters: 0
# dhcp: true
# password_encryption: true
# password_recovery: true
# private_config_encryption: true
# prompt: true
# slave_log: true
# timestamps:
# - msg: debug
# timestamp: datetime
# - datetime_options:
# localtime: true
# msec: true
# show_timezone: true
# year: true
# msg: log
# timestamp: datetime
# Using rendered
- name: Render the commands for provided configuration
cisco.ios.ios_service:
config:
timestamps:
- msg: log
enable: true
timestamp: datetime
datetime_options:
localtime: true
msec: true
show_timezone: true
year: true
- msg: debug
enable: true
timestamp: datetime
pad: false
password_encryption: true
state: rendered
# ·Task·Output
# -----------
#
# rendered:
# - service dhcp
# - service password-encryption
# - service password-recovery
# - service prompt config
# - service slave-log
# - service timestamps log datetime msec localtime show-timezone year
# - service timestamps debug datetime
# Using parsed
# File: parsed.cfg
# ----------------
#
# no service pad
# service password-encryption
# service tcp-keepalives-in
# service tcp-keepalives-out
# service timestamps debug datetime msec localtime show-timezone year
# service timestamps log datetime msec localtime show-timezone year
# service counters max age 5
- name: Parse the provided configuration
cisco.ios.ios_service:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Task Output
# -----------
#
# parsed:
# counters: 5
# dhcp: true
# password_encryption: true
# password_recovery: true
# prompt: true
# slave_log: true
# tcp_keepalives_in: true
# tcp_keepalives_out: true
# timestamps:
# - datetime_options:
# localtime: true
# msec: true
# show_timezone: true
# year: true
# msg: debug
# timestamp: datetime
# - datetime_options:
# localtime: true
# msec: true
# show_timezone: true
# year: true
# msg: log
# timestamp: datetime
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: |