Hi Ansible community,
I am observing syntax error on attempt to use Jinja2 control structures in
the tasks file:
*Code*
/opt/ansible/roles/network/tasks/network.yml:
> {% if publicavailable|default(False) == False and public|default("") == ""
> and datacenter != "XXX" and datacenter != "YYY" %}
> {% set private_interface = ansible_default_ipv4.interface %}
> {% else %}
> {% set private_interface =
> ansible_default_ipv4.interface|regex_replace('\d+','')|string +
> (ansible_default_ipv4.interface|regex_replace('\D+','')|int+1)|string %}
> {% endif %}
> - name: alias interface on private servers
> template:
> src: if_internal_eth.j2
> dest: /etc/network/interfaces.d/if_{{ private_interface }}_0.cfg
> owner: root
> group: root
> mode: 0644
> when: 'datacenter != "XXX" and datacenter != "YYY" and
> vlan_prefix2|default("") != ""'
*Error*
> fatal: [host.domain.tld]: FAILED! => {"reason": "Syntax Error while
> loading YAML.
> found character that cannot start any token
> The error appears to have been in
> /opt/ansible/roles/network/tasks/network.yml: line 52, column 2, but may
> be elsewhere in the file depending on the exact syntax problem.
> The offending line appears to be:
>
> {% if publicavailable|default(False) == False and public|default(\"\") ==
> \"\" and datacenter != \"XXX\" and datacenter != \"YYY\" %}
> ^ here
> "}
*Versions*
ansible 2.5.10
python version = 2.7.12
Ubuntu 16.04.3 LTS
Kindly advise!
Thank you,
Alex
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a459b886-61a0-43af-a2e4-e77045adf756o%40googlegroups.com.