question relative to include + with_items deprecation in 1.5

Hello,

I saw the deprecation warning appear today.

Will this also apply to " role + with_items " ?

I have no “include + with_items” but several “role + with_item” and the deprecation warning also shows on my roles + with_items

If the deprecation warning also stands for the roles, maybe it would be better to update the deprecation message.

What is the best practice as a replacement ? use with_items only at the task level ?

Thank you for your help !

Jerome

role + with_items was never documented either. It doesn’t exist. I’m ok with the error text unless you’re saying it doesn’t raise a warning when attached to a role?

Yes, you should loop inside the tasks.

I’m working on a nice way so it’s more obvious how to pass references to variables in without resorting to old style variable references, that will still make this easy to pass parameters to roles that might be lists.

It does raise a warning when using { role + with_items }. I didn’t know I was the only one using the role + with_items !
I will have to modify my scripts.

will you deprecate also the { role + sudo, sudo_user } ?

Thanks

“will you deprecate also the { role + sudo, sudo_user } ?”

no plans for this at all, and I use this feature often.

It’s only an issue with how the “with_items” thing was implemented.

This feature has been intentionally undocumented for many releases because it has been horribly broken and I would like to take steps to finally remove it and keep people from asking questions about it :slight_smile:

Well I knew it did not work with inventory variables and found it was handy to avoid stating roles N times in my playbook.

For instance, I am installing several version of nginx with :

  • { sudo: yes, sudo_user: “{{ item.user }}”, role: nginx, conf: $item, with_items: nginx_instances }

and I like it that the role:nginx is not obscured by with_items all over the place.

but I am certainly wrong as to the extensibility of this scheme on complex inventories.

Imagine that for a good reason you want to install several version of nginx on the same box, how would you organize playbooks / roles ?

thanks

There’s about 5000 posts on with_items on the mailing list, so I am going to skip repeating it again.

The general problem is it doesn’t work with variables in lots of different scopes.

ok thanks.

I did not want to re-open the debate I am trying to modify my playbooks the appropriate way to anticipate the deprecation.

going back to the playbooks ;

Jerome