theko2fi / theko2fi.multipass / 0.3.0 / module / multipass_vm_exec Execute command in a Multipass virtual machine | "added in version" 0.2.0 of theko2fi.multipass" Authors: Kenneth KOFFI (@theko2fi)theko2fi.multipass.multipass_vm_exec (0.3.0) — module
Install with ansible-galaxy collection install theko2fi.multipass:==0.3.0
collections: - name: theko2fi.multipass version: 0.3.0
Executes a command in a Multipass virtual machine.
- name: Run a simple command theko2fi.multipass.multipass_vm_exec: name: foo command: /bin/bash -c "ls -lah" register: result
- name: Print stdout ansible.builtin.debug: var: result.stdout_lines
- name: Run a simple command in a specific working directory theko2fi.multipass.multipass_vm_exec: name: foo command: "ls -la" workdir: /tmp register: result
- name: Run a simple command (stderr) theko2fi.multipass.multipass_vm_exec: name: foo command: /bin/bash -c "echo Hello world! && echo Hello world! > /dev/stderr" register: result
- name: Print stderr lines ansible.builtin.debug: var: result.stderr_lines
name: description: - The name of the virtual machine to execute the command in. required: true type: str command: description: - The command to execute. required: true type: str workdir: description: - The directory to run the command in. type: str
stderr: description: - The standard error output of the virtual machine command. returned: success type: str stdout: description: - The standard output of the virtual machine command. returned: success type: str