netbox.netbox.netbox_cable 模块 – 在 NetBox 中创建、更新或删除电缆
注意
此模块是 netbox.netbox 集合 (版本 3.20.0) 的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install netbox.netbox
。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定: netbox.netbox.netbox_cable
。
netbox.netbox 0.3.0 中的新增功能
概要
创建、更新或删除 NetBox 中的电缆
要求
执行此模块的主机需要以下要求。
pynetbox
参数
参数 |
注释 |
---|---|
证书路径 |
|
定义电缆配置 |
|
电缆的颜色 |
|
与提供商相关的注释 |
|
必须存在于 NetBox 中 |
|
提供商的描述 |
|
电缆的标签 |
|
电缆的长度 |
|
测量电缆长度的单位 选项
|
|
电缆的状态 选项
|
|
电缆可能需要关联的任何标签 |
|
将分配电缆的租户 |
|
端接 A |
|
端接 A 的类型 选项
|
|
端接 B |
|
端接 B 的类型 选项
|
|
电缆的类型 选项
|
|
NetBox API 令牌。 |
|
NetBox 实例的 URL。 必须可被 Ansible 控制主机访问。 |
|
这可以用于覆盖在 plugins/module_utils/netbox_utils.py 中定义的 ALLOWED_QUERY_PARAMS 中指定的 value,并为用户提供对在其环境中使对象唯一的内容的控制。 在 plugins/module_utils/netbox_utils.py 中定义,并为用户提供对在其环境中使对象唯一的内容的控制。 对象在其环境中唯一。 |
|
对象的状态。 选项
|
|
如果为 这仅应在使用自签名证书的个人控制站点上使用。 默认值: |
注释
注意
标签应定义为 YAML 列表
这应使用连接
local
和主机localhost
来运行
示例
- name: "Test NetBox modules"
connection: local
hosts: localhost
gather_facts: false
tasks:
- name: Create cable within NetBox with only required information
netbox.netbox.netbox_cable:
netbox_url: http://netbox.local
netbox_token: thisIsMyToken
data:
termination_a_type: dcim.interface
termination_a:
device: Test Nexus Child One
name: Ethernet2/2
termination_b_type: dcim.interface
termination_b:
device: Test Nexus Child One
name: Ethernet2/1
state: present
- name: Update cable with other fields
netbox.netbox.netbox_cable:
netbox_url: http://netbox.local
netbox_token: thisIsMyToken
data:
termination_a_type: dcim.interface
termination_a:
device: Test Nexus Child One
name: Ethernet2/2
termination_b_type: dcim.interface
termination_b:
device: Test Nexus Child One
name: Ethernet2/1
type: mmf-om4
status: planned
label: label123
color: abcdef
length: 30
length_unit: m
tags:
- foo
state: present
- name: Delete cable within netbox
netbox.netbox.netbox_cable:
netbox_url: http://netbox.local
netbox_token: thisIsMyToken
data:
termination_a_type: dcim.interface
termination_a:
device: Test Nexus Child One
name: Ethernet2/2
termination_b_type: dcim.interface
termination_b:
device: Test Nexus Child One
name: Ethernet2/1
state: absent
返回值
常见的返回值已在此处记录 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
在 NetBox 中创建或已存在的序列化对象 已返回:成功(当 state=present 时) |
|
指示失败的消息或有关已完成工作的提示信息 已返回:始终 |