【问题标题】:What is the correct syntax to filter VMWare inventory in Ansible Tower/AWX using an instance filter?使用实例过滤器在 Ansible Tower/AWX 中过滤 VMWare 库存的正确语法是什么?
【发布时间】:2020-07-16 17:18:22
【问题描述】:

在 Ansible Tower/AWX gui 中,我创建了一个清单,其中包含一个源来轮询我的 VMWare vCenter 实例以查找主机。我引用的文档不包括过滤主机的示例。我正在尝试仅将 CentOS 或 RHEL 系统从 VMware 导入 Tower/AWX。

我试过这个字符串,它没有过滤正确的主机。

{{ config.guestId == "centos*" or config.guestId == "RHEL*" }}

本关于 VMWare 采购清单的 Tower 文档不包含示例。 https://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html?extIdCarryOver=true&sc_cid=701f2000001OH6kAAG#vmware-vcenter

这个关于快速过滤器的 VMware 文档也没有提供示例。 https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.vcenterhost.doc/GUID-2B6A1637-384D-4597-B453-B575F0ECD8A7.html

【问题讨论】:

    标签: linux ansible ansible-inventory ansible-tower ansible-awx


    【解决方案1】:

    此字符串将仅过滤 VMware 来源清单中的 CentOS 或 RHEL 系统。

    {{ config['guestId'] is search("centos*") or config['guestId'] is search("rhel*") }}
    

    我在这里使用了有关测试字符串的文档。我还试图错误地索引配置数组中的元素。

    https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-19
      • 2013-12-17
      • 1970-01-01
      • 2023-04-06
      • 2019-10-05
      相关资源
      最近更新 更多