Setting a variable by conditional in a playbook

I have spent the last few hours trying to find a way to do this and keep running into formatting issues with every suggestion I find.
What I am trying to accomplish is to have a variable that is set based on the value of another variable.

So if {{ group }} == dev* then I want to set uwsgi_env: development
but if {{ group }} == prod* then I want to set uwsgi_env: production

This seems really reasonable, is there a simple way to accomplish this in a playbook?

I just set uwsgi_env in group_vars/{production,development}, but you should be able to do this also use set_fact and when to do the same.​

+1 to group_variables over set_fact. It’s more native and probably more intuitive.

set_fact should only be used for really oddball niche scenarios, like when you need to multiply a number by 10 or round a value, etc.