# Ansible 2.9.11 \> 2.10.3 env lookup giving lookups were disabled from templating error

**URL:** <https://forum.ansible.com/t/ansible-2-9-11-2-10-3-env-lookup-giving-lookups-were-disabled-from-templating-error/34244>\
**Category:** Ansible Project\
**Created:** [November 26, 2020, 12:13pm UTC](https://forum.ansible.com/t/ansible-2-9-11-2-10-3-env-lookup-giving-lookups-were-disabled-from-templating-error/34244 "2020-11-26T12:13:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Hodgson](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Andrew\_Hodgson](https://forum.ansible.com/u/Andrew_Hodgson)\
**Post date:** [November 26, 2020, 12:13pm UTC](https://forum.ansible.com/t/ansible-2-9-11-2-10-3-env-lookup-giving-lookups-were-disabled-from-templating-error/34244/1 "2020-11-26T12:13:55Z")

</div>

Hi,

Doing a soak test on upgrading from Ansible 2.9.11 to 2.10.3 as I want to use some new features in a collection. Getting the following error on the following variable:

deploy\_version: “locally deployed by {{ lookup(‘env’, ‘ANSIBLE\_CALLER\_USERNAME’) }}”

The error being returned is:

Error was a \<class ‘ansible.errors.AnsibleError’\>, original message: The lookup `env` was found, however lookups were disabled from templating

Any suggestions as to what is causing this?

Thanks.  
Andrew.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [November 26, 2020, 12:28pm UTC](https://forum.ansible.com/t/ansible-2-9-11-2-10-3-env-lookup-giving-lookups-were-disabled-from-templating-error/34244/2 "2020-11-26T12:28:44Z")

</div>

Hi,

that change was apparently caused by [https://github.com/ansible/ansible/pull/69278](https://github.com/ansible/ansible/pull/69278)

I have no idea why it was made, though.

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Andrew\_Hodgson](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Andrew\_Hodgson](https://forum.ansible.com/u/Andrew_Hodgson)\
**Post date:** [November 26, 2020, 4:43pm UTC](https://forum.ansible.com/t/ansible-2-9-11-2-10-3-env-lookup-giving-lookups-were-disabled-from-templating-error/34244/3 "2020-11-26T16:43:43Z")

</div>

Felix Fontein wrote:

> Hi,

> that change was apparently caused by [https://github.com/ansible/ansible/pull/69278](https://github.com/ansible/ansible/pull/69278)

> I have no idea why it was made, though.

I have done further digging on this and come up with the following:

The template in question is actually used as part of a dictionary:

```auto
# Define the resource tags
# If not updated by the CI system, put a placeholder deploy tag which indicates local deployment
# ANSIBLE_CALLER_USERNAME environment variable is set using the Docker wrapper script
deploy_version: "locally deployed by {{ lookup('env', 'ANSIBLE_CALLER_USERNAME') }}"

resource_tags:
  Platform: "{{ platform_name }}"
  Stage: "{{ environment_type }}"
  DeployTag: "{{ deploy_version }}"

```

If I print this out in a debug statement then the tags dictionary is correct and also resources are deployed using the correct tags data. The part that is failing is an assertion:

```auto
- name: Validate variables that need to be defined by calling role
  assert:
    that: "{{ item }} is defined"
    msg: "Variable {{ item }} is not defined"
    quiet: yes
  with_items: "{{ required_vars | default ([]) }} "

```

In this example resource\_tags is in a list of required\_vars we want defining and its giving us the error at the point it tries to assert the variable exists.

Thanks.  
Andrew.
