maxhoesel.proxmox.lxc_container role – Creates and bootstraps a LXC container on a Proxmox VE node for usage with Ansible
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.
Entry point main – Creates and bootstraps a LXC container on a Proxmox VE node for usage with Ansible
Synopsis
This role creates a new LXC container on a proxmox host, connects to it over the proxmox hosts shell and bootstraps it by installing a SSH server and Python. This then allows for access from Ansible like normal.
To execute this role, Ansible needs to access the Proxmox host on which the container will be created. To speficy the host, set
pve_hostto 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 theadd_hostmodule - see the role README for an example.This role has been tested on the following container templates: - Ubuntu 20.04 - Debian 10 - Fedora 32 - CentOS 7/8 - OpenSUSE 15.2 - Alpine 3.12 Other distributions should work as well, as long as they: - use a package manager also used by one of the above distros - use systemd for service management (or rc for Alpine)
The following python modules are required on the controller: - proxmoxer - requests
The main use for this role is to create an Ansible-compatible container image for consumption by the
lxc_container_to_ostemplaterole that you can then deploy with Ansible directly. 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 |
|---|---|
Additional arguments to be passed to the proxmox module when creating the container. See here for details about valid parameters Default: |
|
Set this to yes to run a simple bootstrap script on the container after creation. The script will prepare the container for Ansible (SSH server + Python) Choices:
|
|
Hostname of the LXC container to create Must be a valid PVE container name |
|
OS Template to create the new container from Default: |
|
Automatically download the specified base template from the PVE repository if the image is not present Choices:
|
|
Increase this value if you are experiencing timeout errors during PVE API tasks Default: |
|
Hostname under which the PVE API is reachable This will usually the same as pve_host, except in cases where you are running the API behind a proxy of some sort Default: |
|
Password with which to connect to the API |
|
Username with which to connect to the API Default: |
|
Inventory hostname of the PVE host to create the container on. Ansible will connect to this host. |