是否可以以编程方式从另一个 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)