Ansible to get config and randomly ANSI code in output


We are using Ansible to get config from our VyOS and sometimes some ANSI code are coming in the middle of the output.

It did not happen with 1.2 release but happens now with the latest rolling.

ansible-playbook plbks/get_config.yml | grep “\\u001b[m”

        "                    network-group MGMT\u001b[m",
        "        description VLAN106\u001b[m",

ansible-playbook plbks/get_config.yml | grep “\\u001b[m”

        "set firewall group port-group PG-UDP-DC1 port '123'\u001b[m",
        "                    network-group MGMT\u001b[m",
        "                new enable\u001b[m",

Any idea from where it could come from ?

Thank you for your work and for your help.


Could it be that you have by accident included bad characters which VyOS didnt properly sanitize before storing it in its config.boot file?

And does this occur in random or always at the same place in config?

Could you verify this by using something similar to:

grep -i network-group /config/config.boot | hexdump -C

The whitespaces should read 0x20.


grep -i network-group /config/config.boot | hexdump -C | grep 0x20
grep -i network-group /config/config.boot | hexdump -C | wc
166 3159 13033

The file seems to be clean, it is only when Ansible get it with this ansible commands:

  • name: Get version remote GWxx
    - show version
    - show configuration commands
    - show configuration

So when you fetch it the first time the odd chars shows up at some random places. You fetch the same command again and the odd chars shows now up at different random places?

Sounds like some bad RAM or bad storage is in play here?

Yes, different places, randomly.
Not odd chars but ANSI code (reset color) invisible on console or tty but if you redirect on a file, they are on file.

There was a discussion at slack regarding failed upgrades (add system image) which seems to be a known thing but hard to replicate since they seem to occur at random.

That is you upgrade to a new version (could be from one to another rolling release) but the configuration fails the migration. If you save the configuration at this point sections will be missing (compared to how the config was before the upgrade).

The workaround for this is (credit Sander) to reapply the upgrade twice (with a reboot in between to the old version) like so:

  1. add system image
  2. reboot
  3. Check if it works or not. Works, then \o/. Fail the goto 4.
  4. reboot into old image selecting it in grub
  5. delete system image
  6. add system image again
  7. reboot
  8. This always works for me ™

A theory is if what you see through ansible could be related to the above?

That is if bogus characters shows up during migration phase of the upgrade then of course that section of the config would fail. But it doesnt explain why reapply the same upgrade would fix this issue.

Is the above something you could test with your installation and see if it resolves anything?

Thank you for your answer.

I am afraid I perhaps did not explain correctly the issue.

There is no odd chars in config file stored in vyos appliance, therefore no problem occurs during upgrade nor reboot.

It is only when this file is get with ansible command show configuration , then some ANSI reset color code are randomly inserted into.

This issue happens with all last rolling releases and did not with 1.2 release.

Maybe this as a band-aid until things are figured out? I’m wondering since xterm supports a subset of ANSI could a different terminal type be used? xterm-mono or VT220?

Snippet of ENV variables
vyos@vyos:~$ env
SSH_CLIENT= 55241 22