Help in expressing a task in ansible

Hello,

I have the following task for user management, that I’m trying to express in ansible :

User data is in a users key (vars/users.yml)
Host group data is in a host_groups keys ( vars/groups.yml)

The users key contains the list of users and their data, e.g. :

users:

  • name: test
  • shell: /bin/bash

host_groups:

  • nginx : test1, test2, test3
  • db : test3

What I want to do is write a playbook to iterate over the host_groups, get the list of users to add, and then use the users key to get the data to add a user.

I have a add_user.yml task that takes a user + host to add the user to. But to do this, I need something like :

tasks:

  • include: add_user.yml user=item.user
    with_items:
  • host_groups

But I get a message that include+with_items is deprecated. How do I get the above working? Or is there a better way to do this?

Thanks,
Raghu