xlab_si.nuage_miq_automate
Ansible 角色:nuage_miq_automate
此角色访问 ManageIQ 自动化工作空间,提供 Nuage 凭证(变量 nuage_auth
)和 EMS 事件数据(变量 event
)。
- Nuage 凭证。格式与 Nuage Ansible 模块 要求完全一致,可以直接使用:
nuage_auth:
api_username: 用户名
api_password: 密码
api_enterprise: 企业
api_url: https://nuagedemo.net:8443
api_version: v5_0
- EMS 事件数据。在这里可以访问事件详情,并用于您想运行的任何回调。
event:
#
# 事件发出的 EMS ID。
#
ems_id: '2'
#
# 事件类型(与 `full_data.type` 相同)。
#
type: CREATE
#
# 事件触发的实体类型(与 `full_data.entityType` 相同)。
#
entityType: enterprise
#
# 事件触发的实体(与 `full_data.entities[0]` 相同)。
#
entity:
entity_type: enterprise
ID: 07f2726a-7f83-4826-87bd-7f7664803938
name: DEMO3
# ... 其他属性
#
# 从 Nuage 服务器接收的整个事件哈希。
#
full_data:
assoicatedEvent: false
diffMap:
enterpriseName: csp
entities:
- entityType: enterprise
ID: 07f2726a-7f83-4826-87bd-7f7664803938
name: DEMO3
# ...
entityType: enterprise
entityVersion:
eventReceivedTime: 1535011120658
ignoreDiffInMediationEvents: false
requestID: 62c58aa6-4150-46c7-95fe-ed4051e70864
sourceEnterpriseID: 07f2726a-7f83-4826-87bd-7f7664803938
type: CREATE
updateMechanism: DEFAULT
userName: xlab
请查看这篇 博客文章 以更好地理解此角色的用途。还有一段 YouTube 视频,展示了它的完整用法。
要求
您需要在运行 nuage_miq_automate 角色的自动化实例上定义以下属性:
nuage_username
例如 用户nuage_password
(加密)例如 密码nuage_enterprise
例如 企业nuage_url
例如 https://nuagedemo.net:8443nuage_api_version
例如 v5_0
此角色的主要目的是从自动化工作空间中提取这些属性。
注意:您不必在每个自动化实例上都指定这五个属性。相反,您可以修改模式并在其中设置 默认值 - 然后一个类的所有实例都可以访问它们。这样,如果您的凭证发生变化,只需更新这些默认值即可。
角色变量
变量 | 默认值 | 描述 |
---|---|---|
manageiq | / | 自动化设置。 |
manageiq_connection | / | 自动化设置。 |
manageiq:
X_MIQ_Group: Tenant My Company access
api_token: 2d5d9031361a6ac570d810406f267cea
api_url: 'http://localhost:4000'
automate_workspace: automate_workspaces/82632486-7529-45c6-8fa7-fc53ebbb157d
group: groups/1
user: users/1
manageiq_connection:
X_MIQ_Group: Tenant My Company access
token: 2d5d9031361a6ac570d810406f267cea
url: 'http://localhost:4000'
您不必担心角色输入,因为 ManageIQ 自动化会为您提供这些信息。
输出
此角色为您设置以下变量:
统计名称 | 描述 |
---|---|
nuage_auth | Nuage 认证哈希。可以直接传递给 nuage_vspk 模块。 |
event | EMS 事件数据,见下文。 |
object | 当前自动化实例的绝对名称。 |
event:
type: CREATE
ems_id: 4
entity_type: subnet
full_data: { ... } # 从 Nuage 提供程序发出的完整事件数据
entity: { ... } # event['entities'].first
依赖关系
此角色需要以下角色,这些角色也可在 Ansible Galaxy 上找到:
示例剧本
假设我们希望在每次创建新企业时创建一个域模板。我们只需挂钩这样的剧本:
- name: Nuage 事件回调示例
hosts: localhost
connection: local
gather_facts: False
roles:
- xlab_si.nuage_miq_automate
tasks:
- debug: msg="我是一段作为事件回调运行的剧本,我能够访问 nuage 凭证"
- debug: var=nuage_auth
- debug: msg="以及触发我的事件的详细信息"
- debug: var=event
- debug: msg="所以我现在准备开始工作!"
- name: 在企业上创建域模板
delegate_to: localhost
nuage_vspk:
auth: "{{ nuage_auth }}" # notice how we just pass forward the `nuage_auth`
type: DomainTemplate
parentType: Enterprise
parentId: "{{ event.entity.ID }}" # notice how we just access the `event` variable
state: present
properties:
name: "演示域模板"
来响应 nuage_enterprise_create
事件。完成 :)
许可证
BSD
关于项目
This role accesses ManageIQ Automation Workspace for you to provide you with Nuage credentials and EMS event data.
安装
ansible-galaxy install xlab_si.nuage_miq_automate
许可证
Unknown
下载
147
拥有者
Research and development company based in Ljubljana, Slovenia.