I have a requirement I want to use loop to create connector for kafka, I want to use table list in want to use config that will create configs for kafka connectors. for example(this is random example)
- name: Add-user-{{item}} # I want to use varaible in task name
ansible.builtin.user:
name: "{{ item }}"
state: present
groups: "wheel"
loop:
- testuser1
- testuser2
Want to use loop in task description
The recommended approach would be to use
loopwithlabel.A minimal example playbook
will result into an output of
Because it is adding files, complexity, I/O operations to your Use Case, a less recommended approach with
include_tasksmodule – Dynamically include a task list is shown in the following minimal example playbookusing a separate task file
add_user.ymlresulting into an output of
Documentation and Further Readings
labelloopvariablesinclude_tasksandimport_tasks?