Define variable with a loop

Hi All,

I’m a new (and enthousiast !) user of ansible.
I’m trying to set up an automated way of handling the development environments of our team, using Ansible and some publicly available roles, in particular https://github.com/geerlingguy/ansible-role-mysql

I’m currently facing a problem that I can’t solve, although I digged dozens of ressources (including of course the documentation…). I assume that I don’t take the problem in the right way…

I use facts to define the projects wich need to be set up on the host : this file is in /etc/ansible/facts.d/config.fact on the host

{ "vm_name": "myVM", "whoami": "Me", "environnementType": "lamp", "projects": [ { "project_name": "myProject1", "projectType": "sf2" }, { "project_name": "myProject2", "projectType": "sf1" } ] }

And I want to loop other this data to create one database for each project.
The role waits for a variable called mysql_databases, containing a list of names.

…I can’t achieve in any way to have a “with_items” loop to work : not in the “vars” section of my playbook, not in the “roles” section (I get an “Item not defined”), and the tasks are executed after the role.

Any help would be greatly appreciated : thank you in advance.