theko2fi.multipass.multipass_vm_exec (0.3.0) — module

Execute command in a Multipass virtual machine

| "added in version" 0.2.0 of theko2fi.multipass"

Authors: Kenneth KOFFI (@theko2fi)

Install collection

Install with ansible-galaxy collection install theko2fi.multipass:==0.3.0


Add to requirements.yml

  collections:
    - name: theko2fi.multipass
      version: 0.3.0

Description

Executes a command in a Multipass virtual machine.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run a simple command
  theko2fi.multipass.multipass_vm_exec:
    name: foo
    command: /bin/bash -c "ls -lah"
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print stdout
  ansible.builtin.debug:
    var: result.stdout_lines
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run a simple command in a specific working directory
  theko2fi.multipass.multipass_vm_exec:
    name: foo
    command: "ls -la"
    workdir: /tmp
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print stderr lines
  ansible.builtin.debug:
    var: result.stderr_lines

Inputs

    
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

Outputs

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