maxhoesel.proxmox.lxc_container_to_ostemplate role – Converts a LXC container into an ostemplate that can be used to generate new containers

Note

This role is part of the maxhoesel.proxmox collection (version 5.1.1).

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 maxhoesel.proxmox.

To use it in a playbook, specify: maxhoesel.proxmox.lxc_container_to_ostemplate.

Entry point main – Converts a LXC container into an ostemplate that can be used to generate new containers

Synopsis

  • This role performs the following actions: 1. Creates a gz-compressed backup of a given container with vzdump 2. Moves the backup into the templates location of a given storage volume

  • To execute this role, Ansible needs to access the Proxmox host on which the container will be created. To speficy the host, set pve_host to the hots’ inventory name. If you don’t want to add the host to your inventory file, you can also add it at runtime with the add_host module - see the role README for an example.

  • The main use for this role is to create an Ansible-compatible container image by consuming images created with the lxc_container role. If you are looking for a more general solution to deploy LXC containers, I recommend looking into the community.general.proxmox module (that also powers this role) or, for a more Infrastructure-as-Code oriented approach, Terraform.

Parameters

Parameter

Comments

lxcostemplate_hostname

string

Hostname of the container to convert into an image

lxcostemplate_vmid overwrites this parameter

lxcostemplate_image

string / required

Name of the ostemplate image to generate. .tar.gz will be appended automatically

lxcostemplate_overwrite

boolean

Set to yes if you want to overwrite an already existing image

Choices:

  • false ← (default)

  • true

lxcostemplate_storage

string

Name of the storage volume under which the ostemplate will be saved

Default: "local"

lxcostemplate_vmid

integer

VMID of the container to convert into an image

Takes precedence over lxcostemplate_hostname

lxcostemplate_vzdump_mode

string

Select the type of vzdump backup to perform. Options are stop, suspend and snapshot

Choices:

  • "stop"

  • "suspend"

  • "snapshot" ← (default)

pve_host

string / required

Inventory hostname of the PVE host to create the container on. Ansible will connect to this host.