Page MenuHomeVyOS Platform

vyos.vyos.vyos_config can't use templates anymore with ansible 2.19 and 2.20
Closed, ResolvedPublicBUG

Description

With ansible 2.18 is was possible to use a jinja template as src in vyos.vyos.vyos_config (as its documented)

e.g.:

- name: Configure system base
  vyos.vyos.vyos_config:
    src: templates/base.j2
  tags: vyos_base

and base.j2

set system host-name {{ inventory_hostname }}

with 2.18 it worked as expected

whereas with >=2.19 it seems to not use the templating syntax but is trying to apply it as plaintext

TASK [vyos_firewall : Configure system base] ******************************************************************************************************************************************************************************************************************************************************************************
task path: /redacted/tasks/main.yml:2
[ERROR]: Task failed: Action failed: b'set set system host-name{ inventory_hostname }}\r\n\r\n  Configuration path: [set] is not valid\r\n  Set failed\r\n\r\n[edit]\r\r\nnicolas@fw-dev# '
Origin: /redacted/tasks/main.yml:2:3

1 ---
2 - name: Configure system base
    ^ column 3

fatal: [fw.dev]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "backup": false,
            "backup_options": null,
            "comment": "configured by vyos_config",
            "config": null,
            "lines": null,
            "match": "line",
            "save": false,
            "src": "\nset system host-name {{ inventory_hostname }}\n"
        }
    }
}

MSG:

b'set set system host-name{ inventory_hostname }}\r\n\r\n  Configuration path: [set] is not valid\r\n  Set failed\r\n\r\n[edit]\r\r\nnicolas@fw-dev# '

Details

Version
1.4
Is it a breaking change?
Behavior change
Issue type
Bug (incorrect behavior)

Event Timeline

Hi @nicolasberens ,

Thank you for the question.
The latest supported Ansible core version for this collection is 2.18.2
2.19+ unfortunately has a lot of changes that require the code rework, most notably, the community collections we use alongside with ours are not compatible as well (e.g. ansible.netcommon).
There is an issue https://github.com/vyos/vyos.vyos/issues/417 lodged to embrace 2.19+ at some point, but right now we have to wait for the adoption of this version by wider user base.

Viacheslav triaged this task as Normal priority.Dec 8 2025, 9:22 AM

A workaround could be the following:
Old:

vyos_config:
  src: "templates/template.j2"

New:

vyos_config:
    lines: "{{ lookup('template', 'templates/template.j2').splitlines() }}"

Yes, @GideonKuijt ; this is an intentional change to ansible-core from what I understand. They're trying to make the templating operations much more explicit, so some of the places where we were able to automatically have templating have been broken. Thanks for posting the solution here. I expect we'll see this in a few other places that have src: as well.

As we figure out how to support 2.19+ , hopefully we'll be able to address some of these changes as well.

Thanks!

evgmol changed the task status from Open to Blocked.Feb 15 2026, 7:30 PM

@GideonKuijt @gaige
Netcommon v8.4.0 seems to be free of this issue - kindly check for yourself and advise

Thank you

evgmol changed the task status from Blocked to Needs testing.Apr 10 2026, 11:20 PM
evgmol claimed this task.