theko2fi / theko2fi.multipass / 0.3.0 / module / multipass_vm Module to manage Multipass VM Authors: Kenneth KOFFI (@theko2fi)theko2fi.multipass.multipass_vm (0.3.0) — module
Install with ansible-galaxy collection install theko2fi.multipass:==0.3.0
collections: - name: theko2fi.multipass version: 0.3.0
Manage the life cycle of Multipass virtual machines (create, start, stop, delete).
- name: Create a VM with default parameters theko2fi.multipass.multipass_vm: name: foo
- name: Create a VM with custom specs theko2fi.multipass.multipass_vm: name: foo cpus: 2 memory: 2G disk: 5G
- name: Stop a VM theko2fi.multipass.multipass_vm: name: foo state: stopped
- name: Start a VM theko2fi.multipass.multipass_vm: name: foo state: started
- name: Recreate a VM theko2fi.multipass.multipass_vm: name: foo cpus: 4 memory: 2G disk: 10G recreate: true
- name: Delete a VM theko2fi.multipass.multipass_vm: name: foo state: absent
- name: Delete and purge a VM theko2fi.multipass.multipass_vm: name: foo state: absent purge: true
cpus: description: The number of CPUs of the VM. required: false type: int disk: default: 5G description: - Disk space to allocate to the VM in format C(<number>[<unit>]). - Positive integers, in bytes, or with V(K) (kibibyte, 1024B), V(M) (mebibyte), V(G) (gibibyte) suffix. - Omitting the unit defaults to bytes. required: false type: str name: description: - Name for the VM. - If it is C('primary') (the configured primary instance name), the user's home directory is mounted inside the newly launched instance, in C('Home'). required: true type: str image: default: ubuntu-lts description: The image used to create the VM. required: false type: str purge: default: false description: Use with O(state=absent) to purge the VM after successful deletion. type: bool state: choices: - present - started - absent - stopped default: present description: - C(absent) - An instance matching the specified name will be stopped and deleted. - C(present) - Asserts the existence of an instance matching the name and any provided configuration parameters. If no instance matches the name, a virtual machine will be created. - V(started) - Asserts that the VM is first V(present), and then if the VM is not running moves it to a running state. If the VM was deleted, it will be recovered and started. - V(stopped) - If an instance matching the specified name is running, moves it to a stopped state. - Use the O(recreate) option to always force re-creation of a matching virtual machine, even if it is running. required: false type: str memory: default: 1G description: The amount of RAM to allocate to the VM. required: false type: str mounts: description: - Specification for mounts to be added to the VM. - Omitting a mount that is currently applied to a VM will remove it. elements: dict required: false suboptions: gid_map: description: - A list of group IDs mapping for use in the mount. - Use the Multipass CLI syntax C(<host>:<instance>). File and folder ownership will be mapped from <host> to <instance> inside the VM. - Omitting an gid_map that is currently applied to a mount, will remove it. elements: str type: list source: description: - Path of the local directory to mount. required: true type: str target: description: - target mount point (path inside the VM). - If omitted, the mount point will be the same as the source's absolute path. required: false type: str type: choices: - classic - native default: classic description: - Specify the type of mount to use. - V(classic) mounts use technology built into Multipass. - V(native) mounts use hypervisor and/or platform specific mounts. type: str uid_map: description: - A list of user IDs mapping for use in the mount. - Use the Multipass CLI syntax C(<host>:<instance>). File and folder ownership will be mapped from <host> to <instance> inside the VM. - Omitting an uid_map that is currently applied to a mount, will remove it. elements: str type: list type: list version_added: 0.3.0 version_added_collection: theko2fi.multipass recreate: default: false description: Use with O(state=present) or O(state=started) to force the re-creation of an existing virtual machine. type: bool cloud_init: default: None description: Path or URL to a user-data cloud-init configuration. required: false type: str
result: description: - Facts representing the current state of the virtual machine. Matches the multipass info output. - Empty if O(state=absent) or O(state=stopped). - Will be V(none) if virtual machine does not exist. returned: success; or when O(state=started) or O(state=present), and when waiting for the VM result did not fail 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": { "/home/ubuntu/data": { "gid_mappings": [ "0:default" ], "source_path": "/tmp", "uid_mappings": [ "0:default" ] } }, "release": "Ubuntu 22.04.2 LTS", "state": "Running" } } }' type: dict