Skip links

Can’t use jinja2 in deployment files

We recently saw a problem where a user was having trouble doing an install via ./metroae install_everything. The problem: metroae was completing without doing anything. In the output, every component type displayed a message like this:

 [WARNING]: Could not match supplied host pattern, ignoring: vstats


PLAY [vstats] ******************************************************************
skipping: no hosts matched

When we inspected the ansible.log file, we noticed the following:

 [WARNING]:  * Failed to parse /Users/name/nuage-
metro/src/inventory/hosts with ini plugin: /Users/name/nuage-
metro/src/inventory/hosts:21: Expected key=value host variable assignment, got:
dns_domain

 [WARNING]: Unable to parse /Users/name/nuage-
metro/src/inventory/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

Under the covers, MetroÆ reads your deployment files and populates a number of files under src/inventory. This is MetroÆ configuring the Ansible on your behalf. In this case, something went wrong with the generation of the inventory file, src/inventory/hosts. The WARNINGs, above, indicate the problem.

(Aside: Ansible 2.7 has an option to turn these warnings into errors. When we support Ansible 2.7 we will *definitely* turn this option on!)

In this case, the problem is caused by the existence of {{ jinja2 }} notation in the deployment files. For example, vscs.yml contained the following text:

    # < Hostname >
    # Hostname of the VSC instance
    #
    hostname: "vsc.{{ dns_domain }}"

The {{ dns_domain }} is jinja2 substitution format that is not currently supported in MetroÆ v3. The old build_vars.yml format of MetroÆ v2 *did* support this because all variables were defined in the same file. With deployments, dns_domain is defined globally in common.yml, not in vscs.yml.

We are planning to add jinja2 substitution support in a future release. For now, please don’t use it in your deployment files.

Bitnami