小编de-*_*rob的帖子

从另一个 Ansible 模块调用 Ansible 模块?

是否可以以编程方式从另一个 Ansible 模块调用 Ansible 模块?

语境

我一直在通过 Python (ucsmsdk) 和 Ansible 与 Cisco UCS 合作,以创建一种自动化服务配置文件模板(从现在开始的 SPT)的方法。我创建了符合相应 Git 存储库中设置的标准的api模块

虽然我能够使用 Ansible playbook 创建这些 SPT,但它需要大量重复使用的属性来创建每个单独的项目并遵循它们的长链父/子关系。我想删除所有这些重用并通过提供所有参数来简化项目的创建,我需要一次性完成它们的结构。

下面的例子显示了我想要的当前系统。

当前的

tasks:
- name: create ls server
  ls_server_module:
    name: ex
    other_args:
    creds: 
- name: create VNIC Ether
  vnic_ether_module:
    name: ex_child
    parent: ex
    other_args: 
    creds: 
- name: create VNIC Ether If (VLAN)
  vnic_ether_if_module:
    name: ex_child_child
    parent: ex_child
    creds: 
- name: create VNIC Ether
  vnic_ether_module:
    name: ex_child_2
    parent: ex
    other_args: 
    creds: 
Run Code Online (Sandbox Code Playgroud)

想要的

tasks: …
Run Code Online (Sandbox Code Playgroud)

python automation python-2.7 ansible ansible-2.x

5
推荐指数
1
解决办法
1989
查看次数

标签 统计

ansible ×1

ansible-2.x ×1

automation ×1

python ×1

python-2.7 ×1