- name: Get VM hostname via Proxmox jump hosts: proxmox gather_facts: false become: true become_user: root become_method: sudo vars: vm_ip: "192.168.69.253" vm_user: "howard" vm_pass: "Papadopolus0" tasks: - name: Ensure sshpass is installed (for password-based SSH) # English comments as requested ansible.builtin.apt: name: sshpass state: present update_cache: yes - name: Get hostname from VM using argv (no shell, no line breaks) ansible.builtin.command: argv: - sshpass - -p - "{{ vm_pass }}" - ssh - -o - StrictHostKeyChecking=no - -o - ConnectTimeout=10 - "{{ vm_user }}@{{ vm_ip }}" - hostname register: vm_hostname changed_when: false failed_when: vm_hostname.rc != 0 no_log: false # set to true once you move creds into Vault - name: Print VM hostname ansible.builtin.debug: msg: "VM hostname: {{ vm_hostname.stdout | default('N/A') }}"