0

There is a master/slave setup.

Goal:

Set {{ other_host_of_play }} in a jinja2 template. Example;

The content of node1 should contain node2

Tried {{ play_hosts[0] }}, but this sets the first host of the play, instead of the 'other host'.

Kevin C
  • 4,851
  • 8
  • 30
  • 64
  • 2
    Possible duplicate of [How to remove or exclude an item in an Ansible template list?](http://stackoverflow.com/questions/40696130/how-to-remove-or-exclude-an-item-in-an-ansible-template-list) – Konstantin Suvorov Feb 15 '17 at 11:53
  • Can you give us an example of what you have tried before? Some code examples etc. – flxPeters Feb 15 '17 at 11:58

1 Answers1

0

Not sure if I am allowed to do this. But the answer was actually in the post @konstantinSuvorov provided.

{{ play_hosts | difference([inventory_hostname]) }}

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

Community
  • 1
  • 1
Kevin C
  • 4,851
  • 8
  • 30
  • 64
  • 1
    I think the preferred way of handling this is to either vote to close your own question as duplicate or delete it altogether (as it's a duplicate). See http://meta.stackoverflow.com/questions/254647/ability-to-close-my-own-questions-as-duplicates – SztupY Feb 15 '17 at 12:45