<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
<!--- Explain the problem briefly below -->

When we create a playbook with environment variables defined from input variables, if one of the tasks in this playbooks use a template lookup plugin with a start/end string different from default, it also changes the start/end string used to parse the environment variable and breaks its parsing.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
Template Lookup Plugin

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible 2.8.3
  config file = None
  configured module search path = [u'/home/USER/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.16 (default, Apr  6 2019, 01:42:57) [GCC 8.3.0]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below

```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
Distributor ID:	Ubuntu
Description:	Ubuntu 19.04
Release:	19.04
Codename:	disco

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

Create the playbook presented below, also create an empty file called dummy.yaml.j2.

Execute the playbook with `ansible-playbook playbook.yaml -e test_entry=lalala`

<!--- Paste example playbooks or commands between quotes below -->
```yaml
# Bug example
- hosts: localhost
  gather_facts: false
  
  environment:
    TEST_ENV: "{{ test_entry }}"

  tasks:

  - name: Test 1
    command: "echo ${TEST_ENV} {{ lookup('template', 'dummy.yaml.j2') }}"
    register: output
  
  - debug:
      msg: "{{ output.stdout }}"

  - name: Test 2
    command: "echo ${TEST_ENV} {{ lookup('template', 'dummy.yaml.j2', variable_start_string='[%', variable_end_string='%]') }}"
    register: output

  - debug:
      msg: "{{ output.stdout }}"

  - name: Test 3
    command: "echo ${TEST_ENV} {{ lookup('template', 'dummy.yaml.j2', variable_start_string='[%', variable_end_string='%]') }}"
    environment:
      TEST_ENV: "[% test_entry %]"
    register: output

  - debug:
      msg: "{{ output.stdout }}"

```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
The expected result was that Debug 1 and 2 output the correct result "lalala" and Debug 3
output output "[% test_entry %]" as it is just a workaround to the bug.

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

What happened was that debug 1 had the right output, debug 2 had the variable parsing broken by the lookup and debug 3 worked as a workaround to the issue, which should not be necessary.

<!--- Paste verbatim command output between quotes -->
```paste below
USER@USER-note:~/workspace/tf-infra$ansible-playbook -e test_entry=lalala playbooks/test.yaml -vvvv
ansible-playbook 2.8.3
  config file = None
  configured module search path = [u'/home/USER/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 2.7.16 (default, Apr  6 2019, 01:42:57) [GCC 8.3.0]
No config file found; using defaults
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass it's verify_file() method
 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python2.7/dist-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: test.yaml ***************************************************************************************************************************************************************
Positional arguments: playbooks/test.yaml
become_method: sudo
inventory: (u'/etc/ansible/hosts',)
forks: 5
tags: (u'all',)
extra_vars: (u'test_entry=lalala',)
verbosity: 4
connection: smart
timeout: 10
1 plays in playbooks/test.yaml

PLAY [localhost] ******************************************************************************************************************************************************************
META: ran handlers

TASK [Test 1] *********************************************************************************************************************************************************************
task path: /home/USER/workspace/playbooks/test.yaml:10
File lookup using /home/USER/workspace/playbooks/dummy.yaml.j2 as file
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: USER
<127.0.0.1> EXEC /bin/sh -c 'echo ~USER && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/USER/.ansible/tmp/ansible-tmp-1565035196.17-187587540004383 `" && echo ansible-tmp-1565035196.17-187587540004383="` echo /home/USER/.ansible/tmp/ansible-tmp-1565035196.17-187587540004383 `" ) && sleep 0'
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/commands/command.py
<127.0.0.1> PUT /home/USER/.ansible/tmp/ansible-local-299637oQZ14/tmpFL3AO6 TO /home/USER/.ansible/tmp/ansible-tmp-1565035196.17-187587540004383/AnsiballZ_command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/USER/.ansible/tmp/ansible-tmp-1565035196.17-187587540004383/ /home/USER/.ansible/tmp/ansible-tmp-1565035196.17-187587540004383/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'TEST_ENV=lalala /usr/bin/python /home/USER/.ansible/tmp/ansible-tmp-1565035196.17-187587540004383/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/USER/.ansible/tmp/ansible-tmp-1565035196.17-187587540004383/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": [
        "echo", 
        "${TEST_ENV}"
    ], 
    "delta": "0:00:00.002597", 
    "end": "2019-08-05 16:59:56.387369", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo ${TEST_ENV} ", 
            "_uses_shell": false, 
            "argv": null, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "stdin_add_newline": true, 
            "strip_empty_ends": true, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2019-08-05 16:59:56.384772", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "lalala", 
    "stdout_lines": [
        "lalala"
    ]
}

TASK [debug] **********************************************************************************************************************************************************************
task path: /home/USER/workspace/playbooks/test.yaml:14
ok: [localhost] => {
    "msg": "lalala"
}

TASK [Test 2] *********************************************************************************************************************************************************************
task path: /home/USER/workspace/playbooks/test.yaml:17
File lookup using /home/USER/workspace/playbooks/dummy.yaml.j2 as file
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: USER
<127.0.0.1> EXEC /bin/sh -c 'echo ~USER && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/USER/.ansible/tmp/ansible-tmp-1565035196.46-279367437516145 `" && echo ansible-tmp-1565035196.46-279367437516145="` echo /home/USER/.ansible/tmp/ansible-tmp-1565035196.46-279367437516145 `" ) && sleep 0'
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/commands/command.py
<127.0.0.1> PUT /home/USER/.ansible/tmp/ansible-local-299637oQZ14/tmpriIGjL TO /home/USER/.ansible/tmp/ansible-tmp-1565035196.46-279367437516145/AnsiballZ_command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/USER/.ansible/tmp/ansible-tmp-1565035196.46-279367437516145/ /home/USER/.ansible/tmp/ansible-tmp-1565035196.46-279367437516145/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'TEST_ENV='"'"'{{ test_entry }}'"'"' /usr/bin/python /home/USER/.ansible/tmp/ansible-tmp-1565035196.46-279367437516145/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/USER/.ansible/tmp/ansible-tmp-1565035196.46-279367437516145/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": [
        "echo", 
        "${TEST_ENV}"
    ], 
    "delta": "0:00:00.002174", 
    "end": "2019-08-05 16:59:56.551546", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo ${TEST_ENV} ", 
            "_uses_shell": false, 
            "argv": null, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "stdin_add_newline": true, 
            "strip_empty_ends": true, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2019-08-05 16:59:56.549372", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "{{ test_entry }}", 
    "stdout_lines": [
        "{{ test_entry }}"
    ]
}

TASK [debug] **********************************************************************************************************************************************************************
task path: /home/USER/workspace/playbooks/test.yaml:21
ok: [localhost] => {
    "msg": "{{ test_entry }}"
}

TASK [Test 3] *********************************************************************************************************************************************************************
task path: /home/USER/workspace/playbooks/test.yaml:24
File lookup using /home/USER/workspace/playbooks/dummy.yaml.j2 as file
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: USER
<127.0.0.1> EXEC /bin/sh -c 'echo ~USER && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/USER/.ansible/tmp/ansible-tmp-1565035196.61-117891973732187 `" && echo ansible-tmp-1565035196.61-117891973732187="` echo /home/USER/.ansible/tmp/ansible-tmp-1565035196.61-117891973732187 `" ) && sleep 0'
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/commands/command.py
<127.0.0.1> PUT /home/USER/.ansible/tmp/ansible-local-299637oQZ14/tmpKaHwr_ TO /home/USER/.ansible/tmp/ansible-tmp-1565035196.61-117891973732187/AnsiballZ_command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/USER/.ansible/tmp/ansible-tmp-1565035196.61-117891973732187/ /home/USER/.ansible/tmp/ansible-tmp-1565035196.61-117891973732187/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'TEST_ENV=lalala /usr/bin/python /home/USER/.ansible/tmp/ansible-tmp-1565035196.61-117891973732187/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/USER/.ansible/tmp/ansible-tmp-1565035196.61-117891973732187/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true, 
    "cmd": [
        "echo", 
        "${TEST_ENV}"
    ], 
    "delta": "0:00:00.002216", 
    "end": "2019-08-05 16:59:56.713032", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo ${TEST_ENV} ", 
            "_uses_shell": false, 
            "argv": null, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "stdin_add_newline": true, 
            "strip_empty_ends": true, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2019-08-05 16:59:56.710816", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "lalala", 
    "stdout_lines": [
        "lalala"
    ]
}

TASK [debug] **********************************************************************************************************************************************************************
task path: /home/USER/workspace/playbooks/test.yaml:30
ok: [localhost] => {
    "msg": "lalala"
}
META: ran handlers
META: ran handlers

PLAY RECAP ************************************************************************************************************************************************************************
localhost                  : ok=6    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
```

JINJA2_BEGIN_TOKENS = frozenset(('variable_begin', 'block_begin', 'comment_begin', 'raw_begin'))
JINJA2_END_TOKENS = frozenset(('variable_end', 'block_end', 'comment_end', 'raw_end'))
def generate_ansible_template_vars(path, dest_path=None):
    b_path = to_bytes(path)
    try:
        template_uid = pwd.getpwuid(os.stat(b_path).st_uid).pw_name
    except (KeyError, TypeError):
        template_uid = os.stat(b_path).st_uid
    temp_vars = {
        'template_host': to_text(os.uname()[1]),
        'template_path': path,
        'template_mtime': datetime.datetime.fromtimestamp(os.path.getmtime(b_path)),
        'template_uid': to_text(template_uid),
        'template_fullpath': os.path.abspath(path),
        'template_run_date': datetime.datetime.now(),
        'template_destpath': to_native(dest_path) if dest_path else None,
    }
    managed_default = C.DEFAULT_MANAGED_STR
    managed_str = managed_default.format(
        host=temp_vars['template_host'],
        uid=temp_vars['template_uid'],
        file=temp_vars['template_path'],
    )
    temp_vars['ansible_managed'] = to_text(time.strftime(to_native(managed_str), time.localtime(os.path.getmtime(b_path))))
    return temp_vars
def _escape_backslashes(data, jinja_env):
    """Double backslashes within jinja2 expressions
    A user may enter something like this in a playbook::
      debug:
        msg: "Test Case 1\\3; {{ test1_name | regex_replace('^(.*)_name$', '\\1')}}"