2

Is it possible to use the content of the inventory file (or a dynamic inventory) to create tasks?

For instance, let's say I wanted to configure a monit server dynamically to remotely monitor N websites from the inventory's configured web servers, and to automatically add new entries to its config based on the contents of the inventory?

I'm super open to the idea that I'm approaching it wrong. I do know that I'd like one source of host knowledge, so as close as I can get to that is great.

3

Sure, you can get at an inventory group using the groups variable, and then loop over the items as such:

- name: do stuff
  module_name: foo
  with_items:
    - "{{ groups['group_name'] }}"

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.