Firstly, the dictionaries in YAML are not ordered (and the syntax used by Ansible here is the YAML dictionary), so you have no guarantee that Ansible installed jm_envit before moving on to l_env- you need to divide the assignment into two tasks.
-, - '{{jm_env}}==Develop' - , ; if 'string' true ( , d ).
:
- name: Set the jm_env
set_fact:
jm_env: "{{lookup('env', 'Environment')}}"
- name: Set the l_env
set_fact:
l_env: "{% if jm_env=='Develop' %}d{% elif jm_env=='Staging'%}s{% else %}p{% endif %}"