New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment variables are templated? #12191
Comments
After testing further, it appears I get the |
I |
I cannot duplicate this issue. The only way that I can get that is to have a task with |
Thanks for having a look, @sivel. I currently have this happening with no
|
This could maybe be caused by some data with a |
|
Should I update the top comment? This turns out to happen for me without |
@jimi-c, you pointed me in the right direction. I have some environment variables set that appear to be impacting this -- looks like they're being template-expanded. More info coming |
Got it. If I unset these three environment variables, the problem goes away:
|
So the question is, how are those ending up in the template engine? |
This doesn't trigger it for me: # FOO="{{|}}" ansible-playbook -vv test1.yml Using /etc/ansible/ansible.cfg as config file 1 plays in test1.yml PLAY *************************************************************************** TASK [debug msg=here i am] ***************************************************** ok: [awxlocal] => { "changed": false, "msg": "here i am" } PLAY RECAP ********************************************************************* awxlocal : ok=1 changed=0 unreachable=0 failed=0 |
I think it only happens with |
If you're going to |
Just to update here, discussing in IRC too and using local inventory and/or ANSIBLE_INVENTORY=inventory did not work either. |
Hmm, I just noticed my output, when I work around this, includes
after the |
Is it possible you have |
@bretmartin I've just pushed up the above feature branch, if you'd like to give it a test. This essentially creates a wrapper class which sets an attribute for the Templar to signify something shouldn't be templated. Anything coming from the FactCache class will be wrapped with this, meaning we no longer need to introspect values coming from facts. |
Testing: # cat test1.yml - hosts: all gather_facts: yes vars: foo: "{{lookup('env', 'FOO')}}" tasks: - debug: msg="here i am {{foo}}" # FOO="{{|}}" ansible-playbook -vv test1.yml -i inventory Using /etc/ansible/ansible.cfg as config file 1 plays in test1.yml PLAY *************************************************************************** TASK [setup] ******************************************************************* ok: [localhost] TASK [debug msg=here i am {{foo}}] ********************************************* ok: [localhost] => { "changed": false, "msg": "here i am {{|}}" } PLAY RECAP ********************************************************************* localhost : ok=2 changed=0 unreachable=0 failed=0 |
I believe this would have happened regardless of that commit, as the problem lies in the slightly different (and really, better) way that we do variables via hostvars. Before, in v1, facts were searched for jinja2 constructs like {%%} and {{}} and turned into comments to avoid this, but that was slow when the output from the module was large. |
Issue Type:
Ansible Version:
Ansible Configuration:
Environment:
N/A but running on Mac OS X
Summary:
I get
ERROR! template error while templating string: unexpected '|'
when trying to use a jinja2 filter.Steps To Reproduce:
roles/test/tasks/main.yml
:Expected Results:
Successful playbook execution, in this case just printing "baz"
Actual Results:
The text was updated successfully, but these errors were encountered: