---
- name: upgrade node binaries using the node manager
  hosts: all
  tasks:
    - name: upgrade
      ansible.builtin.command:
        # The `omit` filter removes arguments without values
        argv: "{{ command_args | reject('equalto', omit) | list }}"
      vars:
        command_args:
          - safenode-manager
          - upgrade
          - --interval={{ interval }}
          - "{{ '--force' if force_safenode is defined else omit }}"
          - "{{ ('--env=' + env_variables) if env_variables is defined else omit }}"
          - "{{ ('--version=' + safenode_version) if safenode_version is defined else omit }}"
