cisco.ios.ios_service 模块 – 用于配置服务的资源模块。
注意
此模块是 cisco.ios 集合(版本 9.0.3)的一部分。
如果您正在使用 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install cisco.ios
。
要在 playbook 中使用它,请指定:cisco.ios.ios_service
。
cisco.ios 4.6.0 中的新增功能
概要
此模块在 IOS 平台上配置和管理服务属性
参数
参数 |
注释 |
---|---|
服务配置的字典 |
|
Cisco 呼叫回家服务 选项
|
|
压缩 NVRAM 配置文件 选项
|
|
TFTP 加载配置文件 选项
|
|
通过设置最大计数器老化阈值来控制接口计数器的老化 默认值: |
|
启用 DHCP 服务器和中继代理 选项
|
|
禁用基于 IP 粒子的快速分片 选项
|
|
启用 exec 回调 选项
|
|
延迟噪声线路上的 EXEC 启动 选项
|
|
隐藏 telnet 命令中的目标地址 选项
|
|
启用/禁用内部命令 选项
|
|
为每个 exec 启用行号横幅 选项
|
|
记录回溯 选项
|
|
为隐藏/内部命令启用 syslog 消息 选项
|
|
启用 Nagle 的拥塞控制算法 选项
|
|
允许旧脚本使用 slip/ppp 选项
|
|
启用 PAD 命令 选项
|
|
通过 CMNS 连接启用 PAD 选项
|
|
接受 XOT 到 PAD 连接 选项
|
|
允许通过 XOT 连接传出 PAD 选项
|
|
加密系统密码 选项
|
|
密码恢复 选项
|
|
启用私有配置文件加密 选项
|
|
启用模式特定提示 选项
|
|
记录重要的 VTY-Async 事件 选项
|
|
scripting 选项
|
|
用序列号标记日志消息 选项
|
|
slave-coredump 选项
|
|
启用从 IP 的日志功能 选项
|
|
在空闲传入网络连接上生成 keepalive 选项
|
|
在空闲传出网络连接上生成 keepalive 选项
|
|
TCP 小服务器是在路由器中运行的服务器(在 Unix 中称为守护程序),对于诊断很有用。 |
|
启用小型 TCP 服务器(例如,ECHO) 选项
|
|
设置允许的 TCP 小型服务器数量 1 到 2147483647 |
|
对允许的 TCP 小型服务器数量没有限制 选项
|
|
当连接空闲时设置 TCP 窗口为 0 选项
|
|
时间戳调试/日志消息 |
|
日期和时间时间戳的选项 |
|
对时间戳使用本地时区 选项
|
|
在时间戳中包含毫秒 选项
|
|
将时区信息添加到时间戳 选项
|
|
在时间戳中包含年份 选项
|
|
为选定的消息启用时间戳 选项
|
|
时间戳日志或调试消息 选项
|
|
使用日期和时间或系统运行时间的时间戳 选项
|
|
UDP 小服务器是在路由器中运行的服务器(在 Unix 中称为守护程序),对于诊断很有用。 |
|
启用小型 UDP 服务器(例如,ECHO) 选项
|
|
设置允许的 UDP 小型服务器数量 1 到 2147483647 |
|
对允许的 UDP 小型服务器数量没有限制 选项
|
|
启用对第三方收发器的支持 选项
|
|
此选项仅与状态 parsed 一起使用。 此选项的值应该是通过执行命令 show running-config | section ^service|^no service 从 IOS 设备收到的输出。 状态 parsed 从 |
|
配置应保留的状态。 对于 replaced 和 overridden 状态,该模块具有声明相似的行为。 有关更多详细信息,请参阅示例。 选项
|
注意
注意
在 CML 上针对 Cisco IOSXE 版本 17.9.1a 进行了测试。
此模块使用
network_cli
连接。请参阅 https://docs.ansible.org.cn/ansible/latest/network/user_guide/platform_ios.html
示例
# 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
返回值
常见返回值记录在此处 这里,以下是此模块独有的字段
键 |
描述 |
---|---|
模块执行后的最终配置。 返回值: 当发生更改时返回 示例: |
|
模块执行之前的配置。 返回值: 当 state 为 示例: |
|
推送到远程设备的命令集。 返回值: 当 state 为 示例: |
|
从远程设备收集的关于网络资源的事实,以结构化数据的形式呈现。 返回值: 当 state 为 示例: |
|
按照模块 argspec,将 running_config 选项中提供的设备本机配置解析为结构化数据。 返回值: 当 state 为 示例: |
|
任务中提供的配置以设备本机格式呈现(离线)。 返回值: 当 state 为 示例: |