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.

1 Answer 1

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'] }}"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .