theko2fi.multipass.multipass_mount module – Module to manage directory mapping between host and 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_mount.

New in theko2fi.multipass 0.3.0

Synopsis

  • Mount a local directory in a Multipass virtual machine.

  • Unmount a directory from a Multipass virtual machine.

Parameters

Parameter

Comments

gid_map

list / elements=string

A list of group IDs mapping for use in the mount.

Use the Multipass CLI syntax <host>:<instance>.

File and folder ownership will be mapped from <host> to <instance> inside the VM.

Default: []

name

string / required

Name of the virtual machine to operate on.

source

string

Path of the local directory to mount

Use with state=present to mount the local directory inside the VM.

state

string

absent Unmount the target mount point from the VM.

present Mount the source directory inside the VM. If the VM is not currently running, the directory will be mounted automatically on next boot.

Choices:

  • "absent"

  • "present" ← (default)

target

string

target mount point (path inside the VM).

If omitted when state=present, the mount point will be the same as the source’s absolute path.

If omitted when state=absent, all mounts will be removed from the named VM.

type

string

Specify the type of mount to use.

classic mounts use technology built into Multipass.

native mounts use hypervisor and/or platform specific mounts.

Choices:

  • "classic" ← (default)

  • "native"

uid_map

list / elements=string

A list of user IDs mapping for use in the mount.

Use the Multipass CLI syntax <host>:<instance>.

File and folder ownership will be mapped from <host> to <instance> inside the VM.

Default: []

Examples

- name: Mount '/root/data' directory from the host to '/root/data' inside the VM named 'healthy-cankerworm'
  theko2fi.multipass.multipass_mount:
    name: healthy-cankerworm
    source: /root/data

- name: Mount '/root/data' to '/tmp' inside the VM
  theko2fi.multipass.multipass_mount:
    name: healthy-cankerworm
    source: /root/data
    target: /tmp
    state: present

- name: Unmount '/tmp' directory from the VM
  theko2fi.multipass.multipass_mount:
    name: healthy-cankerworm
    target: /tmp
    state: absent

- name: Mount directory, set file and folder ownership
  theko2fi.multipass.multipass_mount:
    name: healthy-cankerworm
    source: /root/data
    target: /tmp
    state: present
    type: classic
    uid_map:
      - "50:50"
      - "1000:1000"
    gid_map:
      - "50:50"

- name: Unmount all mount points from the 'healthy-cankerworm' VM
  theko2fi.multipass.multipass_mount:
    name: healthy-cankerworm
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

result

dictionary

Empty if state=absent.

Returned: when state=present

Sample: {"gid_mappings": ["0:default"], "source_path": "/root/tmp", "uid_mappings": ["0:default"]}

Authors

  • Kenneth KOFFI (@theko2fi)