1

I'd like to make Ansible run a task per some object found at runtime. For example one per file in a specified directory or one per running process. Is there a way to implement this inside of task/playbook? I'd like the result to be integrated into the normal output as a task in its own rights, ideally with adjusted task and "register" variable name.

Unfortunately all the examples I can find are static definitions.

1 Answer 1

1

You can use a include for this. Here is an example where i read all databases in a mysql host and then include some tasks. You can also give some variables to this include.

- command: mysql -u root -e 'show databases;'
  register: databases

- include: soma_tasks.yml db={{item}}
  with_items: databases.stdout_lines
  when: item not "Database"

You must log in to answer this question.

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