Page MenuHomeVyOS Platform

Re-instate (vyos.vyos.vyos_command) module parameter support for answer, prompt
Closed, ResolvedPublicBUG

Description

  • CUSTOMER MESSAGE START ----

$ ansible-galaxy collection list | grep -i vyos
vyos.vyos 6.0.0
$ ansible-playbook -u admin -i ../inventory.ini site.yaml
...
$ ansible-playbook -u admin -i ../inventory.ini site.yaml
TASK [Add VyOS 1.4.4-hyper-v if it's not present] ***********************************
task path: ~/ansible_vyos/tasks/update.yaml:52
[ERROR]: Task failed: Action failed: Unsupported parameters for (vyos.vyos.vyos_command) module: answer, prompt. Supported parameters include: commands, interval, match, retries, wait_for (waitfor).
Origin: ~/ansible_vyos/tasks/update.yaml:52:7
50 # set environment variable TERM to dumb to
51 # trigger skipping the progress bar
52 - name: Add VyOS 1.4.4-hyper-v if it's not present

^ column 7

fatal: [vyos-bit]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (vyos.vyos.vyos_command) module: answer, prompt. Supported parameters include: commands, interval, match, retries, wait_for (waitfor)."}
$ cat tasks/update.yaml
...

  1. set environment variable TERM to dumb to
    1. trigger skipping the progress bar
    2. name: Add VyOS 1.4.4-hyper-v if it's not present when: system_images.stdout_lines | select("search", "1.4.4") | list | length == 0 vyos.vyos.vyos_command: commands:
      • "TERM=dumb && add system image http://remote.server.org//VyOS/vyos-1.4.4-hyperv-amd64.iso" prompt:
      • "What would you like to name this image"
      • "Would you like to set the new image as the default one for boot"
      • "An active configuration was found. Would you like to copy it to the new image"
      • "Would you like to copy SSH host keys" answer:
      • "1.4.4"
      • "Yes"
      • "Yes"
      • "Yes" vars: ansible_command_timeout: 180

...
yet the prompt and answer parameters are still in the current documentation: https://docs.ansible.com/projects/ansible/latest/collections/vyos/vyos/vyos_command_module.html#notes
which stands If a command sent to the device requires answering a prompt, it is possible to pass a dict containing command, answer and prompt. See examples.
I suspect this got lost in the, big announced, 6.0.0 release. https://blog.vyos.io/vyos-ansible-collection-6.0.0-release
I am open to any other Ansible solutions to update/upgrade. It’s been a troubled road for two years now https://forum.vyos.io/t/add-system-image-http-with-ansible/12784

Details

Version
6.0.0
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

This does not look like a bug but rather as the module mis-use:

The module syntax is different as per vyos.vyos.vyos_command module – Run one or more commands on VyOS devices — Ansible Community Documentation , Namely, commands accept a dictionary of command, prompt and answer

The above is not multi-line, hence one command, one set of prompt/asnwer

I tested with the playbook:

---
- name: Testing all the modules
  hosts: vyos_lab
  gather_facts: false
  tasks:
    - name: Test answer & prompt
      vyos.vyos.vyos_command:
        commands:
          - command: reboot
            prompt: "Are you sure you want to reboot this system (target15x)? [y/N] "
            answer: N
      vars:
        ansible_command_timeout: 20
        ansible_connection: ansible.netcommon.network_cli

Which did not result in error message as per the bug report, but the prompt had to be precisely what the target system outputs, or the run will wait and time out, not being able to parse the output and match

@nicolas Fort @Srividya Anantapatnaikuni here is the solution

the answer/prompt is not robust and fails if prompts changed. My new approach is to simply run the add system image with defaults and avoid interaction as much as possible.
Example playbook (upgrading from 1.3.4 to 1.4.3):


  • name: Testing all the modules hosts: vyos_lab gather_facts: false tasks:
  • name: Grab system images vyos.vyos.vyos_command: commands:
    • command: "show system image" register: system_images vars: ansible_command_timeout: 20 ansible_connection: ansible.netcommon.network_cli
  • name: Clean up stale VyOS image install dirs vyos.vyos.vyos_command: commands:
    • command: | TERM=dumb && \ umount /mnt/installation/iso_src 2>/dev/null \ rm -rf /mnt/installation/iso_src vars: ansible_command_timeout: 30
  • name: Download VyOS image install dirs vyos.vyos.vyos_command: commands:
  • name: Install the downloaded VyOS image (non-interactive) vyos.vyos.vyos_command: commands:
    • "echo | add system image /tmp/vyos-1.4.3-generic-amd64.iso" register: install_result

Step “Clean up stale VyOS image install dirs“ is optional

Output:

$ ansible-playbook -i hosts -l vyos134 ./prompt02.yaml -vvvv
ansible-playbook [core 2.18.12]

config file = /home/d368409/work/work12.vyos/lab/ansible/ansible.cfg
configured module search path = ['/home/d368409/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/d368409/work/work12.vyos/lab/ansible/.venv/lib/python3.12/site-packages/ansible
ansible collection location = /home/d368409/work/work12.vyos/lab/ansible/collections
executable location = /home/d368409/work/work12.vyos/lab/ansible/.venv/bin/ansible-playbook
python version = 3.12.12 (main, Jan 10 2026, 21:18:45) [GCC 15.2.1 20251112] (/home/d368409/work/work12.vyos/lab/ansible/.venv/bin/python3.12)
jinja version = 3.1.6
libyaml = True

Using /home/d368409/work/work12.vyos/lab/ansible/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from
script declined parsing /home/d368409/work/work12.vyos/lab/ansible/hosts as it did not pass its verify_file() method
Parsed /home/d368409/work/work12.vyos/lab/ansible/hosts inventory source with ini plugin
Loading collection vyos.vyos from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos
Loading callback plugin default of type stdout, v2.0 from /home/d368409/work/work12.vyos/lab/ansible/.venv/lib/python3.12/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: prompt02.yaml ***************************************
Positional arguments: ./prompt02.yaml
verbosity: 4
connection: ssh
become_method: sudo
tags: ('all',)
inventory: ('/home/d368409/work/work12.vyos/lab/ansible/hosts',)
subset: vyos134
forks: 5
1 plays in ./prompt02.yaml

PLAY [Testing all the modules] ************************************

TASK [Grab system images] *************************************
task path: /home/d368409/work/work12.vyos/lab/ansible/prompt02.yaml:8
Loading collection ansible.netcommon from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/utils
redirecting (type: terminal) ansible.builtin.vyos to vyos.vyos.vyos
redirecting (type: cliconf) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> Using network group action vyos.vyos.vyos for vyos.vyos.vyos_command
<192.168.122.84> attempting to start connection
<192.168.122.84> using connection plugin ansible.netcommon.network_cli
<192.168.122.84> local domain socket does not exist, starting it
<192.168.122.84> control socket path is /home/d368409/.ansible/pc/25e4f89adc
<192.168.122.84> Loading collection ansible.builtin from
<192.168.122.84> Loading collection ansible.netcommon from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/netcommon
<192.168.122.84> Loading collection ansible.utils from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/utils
<192.168.122.84> redirecting (type: terminal) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> Loading collection vyos.vyos from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos
<192.168.122.84> redirecting (type: cliconf) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> local domain socket listeners started successfully
<192.168.122.84> loaded cliconf plugin ansible_collections.vyos.vyos.plugins.cliconf.vyos from path /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py for network_os vyos
<192.168.122.84> ssh type is set to auto
<192.168.122.84> autodetecting ssh_type
<192.168.122.84> ssh type is now set to libssh
<192.168.122.84> Loading collection ansible.builtin from
<192.168.122.84> local domain socket path is /home/d368409/.ansible/pc/25e4f89adc
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: disabled
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: module execution time may be extended
<192.168.122.84> ESTABLISH LOCAL CONNECTION FOR USER: d368409
<192.168.122.84> EXEC /bin/sh -c '( umask 77 && mkdir -p " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp "&& mkdir " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607047.7749739-2057432-272766590983187 " && echo ansible-tmp-1768607047.7749739-2057432-272766590983187=" echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607047.7749739-2057432-272766590983187 " ) && sleep 0'
Using module file /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py
<192.168.122.84> PUT /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/tmp1hkdmqj3 TO /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607047.7749739-2057432-272766590983187/AnsiballZ_vyos_command.py
<192.168.122.84> EXEC /bin/sh -c 'chmod u+rwx /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607047.7749739-2057432-272766590983187/ /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607047.7749739-2057432-272766590983187/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c '/home/d368409/work/work12.vyos/lab/ansible/.venv/bin/python3.12 /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607047.7749739-2057432-272766590983187/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c 'rm -f -r /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607047.7749739-2057432-272766590983187/ > /dev/null 2>&1 && sleep 0'
ok: [vyos134] => {

"changed": false,
"invocation": {
    "module_args": {
        "commands": [
            {
                "answer": null,
                "check_all": false,
                "command": "show system image",
                "newline": true,
                "output": null,
                "prompt": null,
                "sendonly": false
            }
        ],
        "interval": 1,
        "match": "all",
        "retries": 9,
        "wait_for": null
    }
},
"stdout": [
    "The system currently has the following image(s) installed:\n\n   1: 1.3.4 (default boot)"
],
"stdout_lines": [
    [
        "The system currently has the following image(s) installed:",
        "",
        "   1: 1.3.4 (default boot)"
    ]
]

}

TASK [Clean up stale VyOS image install dirs] *********************************
task path: /home/d368409/work/work12.vyos/lab/ansible/prompt02.yaml:17
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.netcommon from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/utils
redirecting (type: terminal) ansible.builtin.vyos to vyos.vyos.vyos
redirecting (type: cliconf) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> Using network group action vyos.vyos.vyos for vyos.vyos.vyos_command
<192.168.122.84> attempting to start connection
<192.168.122.84> using connection plugin ansible.netcommon.network_cli
<192.168.122.84> local domain socket does not exist, starting it
<192.168.122.84> control socket path is /home/d368409/.ansible/pc/d936058a91
<192.168.122.84> Loading collection ansible.builtin from
<192.168.122.84> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<192.168.122.84> Loading collection ansible.netcommon from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/netcommon
<192.168.122.84> Loading collection ansible.utils from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/utils
<192.168.122.84> redirecting (type: terminal) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> Loading collection vyos.vyos from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos
<192.168.122.84> redirecting (type: cliconf) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> local domain socket listeners started successfully
<192.168.122.84> loaded cliconf plugin ansible_collections.vyos.vyos.plugins.cliconf.vyos from path /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py for network_os vyos
<192.168.122.84> ssh type is set to auto
<192.168.122.84> autodetecting ssh_type
<192.168.122.84> ssh type is now set to libssh
<192.168.122.84> Loading collection ansible.builtin from
<192.168.122.84> local domain socket path is /home/d368409/.ansible/pc/d936058a91
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: disabled
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: module execution time may be extended
<192.168.122.84> ESTABLISH LOCAL CONNECTION FOR USER: d368409
<192.168.122.84> EXEC /bin/sh -c '( umask 77 && mkdir -p " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp "&& mkdir " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607049.7949848-2057479-106040361863028 " && echo ansible-tmp-1768607049.7949848-2057479-106040361863028=" echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607049.7949848-2057479-106040361863028 " ) && sleep 0'
Using module file /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py
<192.168.122.84> PUT /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/tmp8vnf9qyx TO /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607049.7949848-2057479-106040361863028/AnsiballZ_vyos_command.py
<192.168.122.84> EXEC /bin/sh -c 'chmod u+rwx /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607049.7949848-2057479-106040361863028/ /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607049.7949848-2057479-106040361863028/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c '/home/d368409/work/work12.vyos/lab/ansible/.venv/bin/python3.12 /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607049.7949848-2057479-106040361863028/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c 'rm -f -r /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607049.7949848-2057479-106040361863028/ > /dev/null 2>&1 && sleep 0'
ok: [vyos134] => {

"changed": false,
"invocation": {
    "module_args": {
        "commands": [
            {
                "answer": null,
                "check_all": false,
                "command": "TERM=dumb && \\\numount /mnt/installation/iso_src 2>/dev/null \\\nrm -rf /mnt/installation/iso_src\n",
                "newline": true,
                "output": null,
                "prompt": null,
                "sendonly": false
            }
        ],
        "interval": 1,
        "match": "all",
        "retries": 9,
        "wait_for": null
    }
},
"stdout": [
    "TERM=dumb && \\\n> umount /mnt/installation/iso_src 2>/dev/null \\\n> rm -rf /mnt/installation/iso_src"
],
"stdout_lines": [
    [
        "TERM=dumb && \\",
        "> umount /mnt/installation/iso_src 2>/dev/null \\",
        "> rm -rf /mnt/installation/iso_src"
    ]
]

}

TASK [Download VyOS image install dirs] ***********************************
task path: /home/d368409/work/work12.vyos/lab/ansible/prompt02.yaml:27
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.netcommon from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/utils
redirecting (type: terminal) ansible.builtin.vyos to vyos.vyos.vyos
redirecting (type: cliconf) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> Using network group action vyos.vyos.vyos for vyos.vyos.vyos_command
<192.168.122.84> attempting to start connection
<192.168.122.84> using connection plugin ansible.netcommon.network_cli
<192.168.122.84> found existing local domain socket, using it!
<192.168.122.84> invoked shell using ssh_type: libssh
<192.168.122.84> ssh connection done, setting terminal
<192.168.122.84> loaded terminal plugin for network_os vyos
<192.168.122.84> firing event: on_open_shell()
<192.168.122.84> ssh connection has completed successfully
<192.168.122.84> updating play_context for connection
<192.168.122.84> Loading collection ansible.builtin from
<192.168.122.84> local domain socket path is /home/d368409/.ansible/pc/d936058a91
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: disabled
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: module execution time may be extended
<192.168.122.84> ESTABLISH LOCAL CONNECTION FOR USER: d368409
<192.168.122.84> EXEC /bin/sh -c '( umask 77 && mkdir -p " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp "&& mkdir " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607051.3921063-2057503-252918979471417 " && echo ansible-tmp-1768607051.3921063-2057503-252918979471417=" echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607051.3921063-2057503-252918979471417 " ) && sleep 0'
Using module file /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py
<192.168.122.84> PUT /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/tmp1b_56ttp TO /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607051.3921063-2057503-252918979471417/AnsiballZ_vyos_command.py
<192.168.122.84> EXEC /bin/sh -c 'chmod u+rwx /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607051.3921063-2057503-252918979471417/ /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607051.3921063-2057503-252918979471417/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c '/home/d368409/work/work12.vyos/lab/ansible/.venv/bin/python3.12 /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607051.3921063-2057503-252918979471417/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c 'rm -f -r /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607051.3921063-2057503-252918979471417/ > /dev/null 2>&1 && sleep 0'
ok: [vyos134] => {

"changed": false,
"invocation": {
    "module_args": {
        "commands": [
            {
                "answer": null,
                "check_all": false,
                "command": "cd /tmp/ && wget http://192.168.122.1/filebin/vyos-1.4.3-generic-amd64.iso",
                "newline": true,
                "output": null,
                "prompt": null,
                "sendonly": false
            }
        ],
        "interval": 1,
        "match": "all",
        "retries": 9,
        "wait_for": null
    }
},
"stdout": [
    "Connecting to 192.168.122.1 (192.168.122.1:80)\n\nvyos-1.4.3-generic-a  23% |*************************************************************************************************************                                                                                                                                                                                                                                                                                                                                                                   |  107M  0:00:03 ETA\nvyos-1.4.3-generic-a  93% |*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************                               |  424M  0:00:00 ETA\nvyos-1.4.3-generic-a 100% |********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************|  454M  0:00:00 ETA"
],
"stdout_lines": [
    [
        "Connecting to 192.168.122.1 (192.168.122.1:80)",
        "",
        "vyos-1.4.3-generic-a  23% |*************************************************************************************************************                                                                                                                                                                                                                                                                                                                                                                   |  107M  0:00:03 ETA",
        "vyos-1.4.3-generic-a  93% |*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************                               |  424M  0:00:00 ETA",
        "vyos-1.4.3-generic-a 100% |********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************|  454M  0:00:00 ETA"
    ]
]

}

TASK [Install the downloaded VyOS image (non-interactive)] ********************************
task path: /home/d368409/work/work12.vyos/lab/ansible/prompt02.yaml:35
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.netcommon from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/ansible/utils
redirecting (type: terminal) ansible.builtin.vyos to vyos.vyos.vyos
redirecting (type: cliconf) ansible.builtin.vyos to vyos.vyos.vyos
<192.168.122.84> Using network group action vyos.vyos.vyos for vyos.vyos.vyos_command
<192.168.122.84> attempting to start connection
<192.168.122.84> using connection plugin ansible.netcommon.network_cli
<192.168.122.84> found existing local domain socket, using it!
<192.168.122.84> updating play_context for connection
<192.168.122.84> Loading collection ansible.builtin from
<192.168.122.84> local domain socket path is /home/d368409/.ansible/pc/d936058a91
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: disabled
<vyos134> ANSIBLE_NETWORK_IMPORT_MODULES: module execution time may be extended
<192.168.122.84> ESTABLISH LOCAL CONNECTION FOR USER: d368409
<192.168.122.84> EXEC /bin/sh -c '( umask 77 && mkdir -p " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp "&& mkdir " echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607053.4519708-2057536-197117501013109 " && echo ansible-tmp-1768607053.4519708-2057536-197117501013109=" echo /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607053.4519708-2057536-197117501013109 " ) && sleep 0'
Using module file /home/d368409/work/work12.vyos/lab/ansible/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py
<192.168.122.84> PUT /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/tmpgdl0mnoc TO /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607053.4519708-2057536-197117501013109/AnsiballZ_vyos_command.py
<192.168.122.84> EXEC /bin/sh -c 'chmod u+rwx /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607053.4519708-2057536-197117501013109/ /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607053.4519708-2057536-197117501013109/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c '/home/d368409/work/work12.vyos/lab/ansible/.venv/bin/python3.12 /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607053.4519708-2057536-197117501013109/AnsiballZ_vyos_command.py && sleep 0'
<192.168.122.84> EXEC /bin/sh -c 'rm -f -r /home/d368409/.ansible/tmp/ansible-local-2057423rtdjh4fp/ansible-tmp-1768607053.4519708-2057536-197117501013109/ > /dev/null 2>&1 && sleep 0'
ok: [vyos134] => {

"changed": false,
"invocation": {
    "module_args": {
        "commands": [
            "echo | add system image /tmp/vyos-1.4.3-generic-amd64.iso"
        ],
        "interval": 1,
        "match": "all",
        "retries": 9,
        "wait_for": null
    }
},
"stdout": [
    "Checking SHA256 checksums of files on the ISO image... OK.\nDone!\nWhat would you like to name this image? [1.4.3]: OK.  This image will be named: 1.4.3\nInstalling \"1.4.3\" image.\nCopying new release files...\nWould you like to save the current configuration \ndirectory and config file? (Yes/No) [Yes]: Copying current configuration...\nWould you like to save the SSH host keys from your \ncurrent configuration? (Yes/No) [Yes]: Copying SSH keys...\nRunning post-install script...\nSetting up grub configuration...\nDone."
],
"stdout_lines": [
    [
        "Checking SHA256 checksums of files on the ISO image... OK.",
        "Done!",
        "What would you like to name this image? [1.4.3]: OK.  This image will be named: 1.4.3",
        "Installing \"1.4.3\" image.",
        "Copying new release files...",
        "Would you like to save the current configuration ",
        "directory and config file? (Yes/No) [Yes]: Copying current configuration...",
        "Would you like to save the SSH host keys from your ",
        "current configuration? (Yes/No) [Yes]: Copying SSH keys...",
        "Running post-install script...",
        "Setting up grub configuration...",
        "Done."
    ]
]

}

PLAY RECAP ****************************************
vyos134 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

The view from the VyOS device:

vyos@vyos1.3:~$ show system image
The system currently has the following image(s) installed:

1: 1.4.3 (default boot)
2: 1.3.4

So it works this way (edited) 

When the playbook runs and the image is already installed - it skips it:

[
    "Checking SHA256 checksums of files on the ISO image... OK.",
    "Done!",
    "What would you like to name this image? [1.4.3]: OK.  This image will be named: 1.4.3",
    "An image named 1.4.3 is already installed on this system.",
    "Proceeding with this installation will delete this copy of",
    "1.4.3 and replace it with a new copy.",
    "Do you want to replace it? (Yes/No) [No]: OK.  Will not replace 1.4.3",
    "Exiting..."
]

otherwise - there is excerpt from the successful update

[
    "Checking SHA256 checksums of files on the ISO image... OK.",
    "Done!",
    "What would you like to name this image? [1.4.3]: OK.  This image will be named: 1.4.3",
    "Installing \"1.4.3\" image.",
    "Copying new release files...",
    "Would you like to save the current configuration ",
    "directory and config file? (Yes/No) [Yes]: Copying current configuration...",
    "Would you like to save the SSH host keys from your ",
    "current configuration? (Yes/No) [Yes]: Copying SSH keys...",
    "Running post-install script...",
    "Setting up grub configuration...",
    "Done."
]

New Playbook

---
- name: Testing all the modules
  hosts: vyos_lab
  gather_facts: false
  tasks:


    - name: Grab system images
      vyos.vyos.vyos_command:
        commands:
          - command: "show system image"
      register: system_images
      vars:
        ansible_command_timeout: 60
        ansible_connection: ansible.netcommon.network_cli


    - name: Clean up stale VyOS image install dirs
      vyos.vyos.vyos_command:
        commands:
          - command: |
              TERM=dumb && \
              umount /mnt/installation/iso_src 2>/dev/null \
              rm -rf /mnt/installation/iso_src
      vars:
        ansible_command_timeout: 30

    - name: Download VyOS image install dirs
      vyos.vyos.vyos_command:
        commands:
          - command: cd /tmp/ && wget http://192.168.122.1/filebin/vyos-1.4.3-generic-amd64.iso
      vars:
        ansible_command_timeout: 30


    - name: Install the downloaded VyOS image (non-interactive)
      vyos.vyos.vyos_command:
        commands:
          - "yes '' | add system image /tmp/vyos-1.4.3-generic-amd64.iso"
      register: install_result