如何在分子中传递额外的清单文件(动态清单脚本)?

How to pass an additional inventory file (dynamic inventory script) in molecule?

在我的剧本中,我使用 var group[inventory_group]。我需要使用我的动态清单脚本。在 the documentation 我发现:

Like above, it is possible to pass an additional inventory file (or even dynamic inventory script), using the hosts key. Ansible will automatically merge this inventory with the one generated by molecule. This can be useful if you want to define extra hosts that are not managed by Molecule.

但是我没有找到任何例子。

那么,如何使用主机密钥“传递额外的清单文件(甚至动态清单脚本)”?

也许你可以在分子场景中执行 createprepare 步骤中的动态清单脚本,然后使用 add_host 模块将主机添加到内存清单中?

所以像这样:

- command:
    cmd: /path/to/your_dynamic_inventory_scri.pt
  delegate_to: localhost
  register: dynamic_inventory


- add_host:
    name: "{{ item }}"
  loop: "{{ dynamic_inventory.stdout_lines }}"