theko2fi.multipass.multipass_vm_exec module – Execute command in a Multipass virtual machine
Note
This module is part of the theko2fi.multipass collection (version 0.3.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install theko2fi.multipass
.
To use it in a playbook, specify: theko2fi.multipass.multipass_vm_exec
.
New in theko2fi.multipass 0.2.0
Synopsis
Executes a command in a Multipass virtual machine.
Parameters
Parameter |
Comments |
---|---|
The command to execute. |
|
The name of the virtual machine to execute the command in. |
|
The directory to run the command in. |
Examples
- 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
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The standard error output of the virtual machine command. Returned: success |
|
The standard output of the virtual machine command. Returned: success |