I have some task which I wish to delegate_to some hosts (finally I want to list them in some var rather than use group from inventory). For this question lets simplify this to (I did exactly the same having a hope it'll help me spot where the problem is):

- name Foo
  delegate_to: "{{ item }}"
    - some.host.in.my.domain

This throws an exception:

Exception: host not found: {{ item }}

Any idea why this doesn't work ? Let me know if you need more details. Thank you in advance for help.

  • There's multiple syntax errors in your yaml - are you sure it looks like that? You have a missing colon after name, and template is misspelled. – Daniel Farrell Dec 15 '14 at 22:51

It's some kind of bug in ansible 1.8.2. I faced same problem in some other place which worked before I made an upgrade.


Assuming a delegate_to host can be specified with a with_items value - and I don't see why that wouldn't work - the problem is that you can't delegate to a non-existent host.

Not all is lost though; the trick here is to add the hosts dynamically before delegating to them. Try using the add_host action to add the hosts into the ansible play. Then, you may be able to delegate to them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.