How to remove or exclude an item in an Ansible template list?

前端 未结 1 1216
野趣味
野趣味 2021-02-13 15:56

I\'m writing an Ansible template that needs to produce a list of ip\'s in a host group, excluding the current hosts IP. I\'ve searched around online an

相关标签:
1条回答
  • 2021-02-13 16:16

    There is difference filter for that:

    - debug: var=item
      with_items: "{{ groups['my_group'] | difference([inventory_hostname]) }}"
    

    This will give you all items hosts from my_group without current host.

    0 讨论(0)
提交回复
热议问题