Skip to content
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

Welcome url scheme template not being parsed correctly... moustaches in deployed file #147

Open
bryanbecker opened this issue Jan 8, 2017 · 7 comments

Comments

@bryanbecker
Copy link

I'm getting the following in my public/index.html:

  <body>
    <div id="content">

      <h2><a href="{{ item.welcome_url_scheme|d("https") }}://myurl.com/">myurl.com</a></h2>

      <p id="http-status"><strong>418 I'm a teapot</strong></p>

    </div>
  </body>
</html>

Clearly the following section of .j2 code is not being parsed how it was intended, but not sure why:

{% if nginx_tpl_domain %}
{%   set nginx_tpl_welcome_title = '<a href="{{ item.welcome_url_scheme|d("https") }}://' + nginx_tpl_domain + '/">' + nginx_tpl_domain + '</a>' %}
{% elif not nginx_tpl_domain %}
{%   set nginx_tpl_welcome_title = '<a href="http://companyname.website/">CompanyName.website</a>' %}
{% endif %}
@drybjed
Copy link
Member

drybjed commented Jan 9, 2017

What Ansible version do you use? Can you try with Ansible 2.2?

@bryanbecker
Copy link
Author

That was 2.2

I'm testing now on a different, clean host.

@bryanbecker
Copy link
Author

Confirming the same result

@bryanbecker
Copy link
Author

{% set nginx_tpl_welcome_title = '<a href="{{ item.welcome_url_scheme|d("https") }}://' + nginx_tpl_domain + '/">' + nginx_tpl_domain + '</a>' %}

After further consideration, the error is almost surely because you can't put a variable expression ({{) inside a statement ({%)

I think something like this might work:

{% set nginx_tpl_welcome_title %}
   <a href="{{ item.welcome_url_scheme|d("https") }}://{{ nginx_tpl_domain }}/"> {{ nginx_tpl_domain }} </a>
{% endset %}

@bryanbecker
Copy link
Author

I tested the above fix locally and it works

@bryanbecker
Copy link
Author

Not sure why the travis tests are failing. The error is:

template error while templating string: expected token '=', got 'end of statement block'

Any ideas?

@drybjed
Copy link
Member

drybjed commented Jan 13, 2017

Not sure yet, I will try to investigate it on latest Ansible 2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants