theko2fi.multipass.multipass_vm_info (0.3.0) — module

Retrieves facts about Multipass virtual machine

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

Retrieves facts about a Multipass virtual machine.

Essentially returns the output of C(multipass info <name>), similar to what M(theko2fi.multipass.multipass_vm) returns for a non-absent virtual machine.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get infos on virtual machine
  theko2fi.multipass.multipass_vm_info:
    name: foo
  register: output
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Does virtual machine exist?
  ansible.builtin.debug:
    msg: "The VM {{ 'exists' if output.exists else 'does not exist' }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print information about virtual machine
  ansible.builtin.debug:
    var: output.result
  when: output.exists

Inputs

    
name:
    description:
    - The name of the virtual machine to inspect.
    required: true
    type: str

Outputs

exists:
  description:
  - Returns whether the virtual machine exists.
  returned: always
  sample: true
  type: bool
result:
  description:
  - Facts representing the current state of the virtual machine. Matches the multipass
    info output.
  - Will be V(none) if virtual machine does not exist.
  returned: always
  sample: '{ "errors": [], "info": { "foo": { "cpu_count": "1", "disks": { "sda1":
    { "total": "5120710656", "used": "2200540672" } }, "image_hash": "fe102bfb3d3d917d31068dd9a4bd8fcaeb1f529edda86783f8524fdc1477ee29",
    "image_release": "22.04 LTS", "ipv4": [ "172.23.240.92" ], "load": [ 0.01, 0.01,
    0 ], "memory": { "total": 935444480, "used": 199258112 }, "mounts": { }, "release":
    "Ubuntu 22.04.2 LTS", "state": "Running" } } }'
  type: dict