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 的日志功能 选项
|
|
在空闲的传入网络连接上生成 keepalives 选项
|
|
在空闲的传出网络连接上生成 keepalives 选项
|
|
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* 从 |
|
配置应保留的状态。 该模块对替换和覆盖状态具有声明性相似的行为。 有关更多详细信息,请参阅示例。 选项
|
注释
注意
在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 为 示例: |