Create lxd container from template with ansible.

dsexton18

Member
Jul 3, 2023
41
1
8
I am trying to create an lxd container using ansible but having no luck. I created an role and added the below to task/main.yml

When the playbook runs I get
Code:
FAILED! => {"changed": false, "msg": "The `lxc` module is not importable. Check the requirements."}
I installed the ansible collection community.general on my ansible control node.

What am i missing?


Code:
- name: Create a started container
  community.general.lxc_container:
    name: test-container-started
    container_log: true
    template: rockeylinux-9-default
    state: started
    template_options: --release trusty
 
I also gave community.general.proxmox collection at try and came up with the below as part of a role.
I am curious what others have found to be the best way to manage containers as code? What ansible collection do you find works best?

Code:
 tasks file for create_lxd
- name: Create new container with minimal options
  community.general.proxmox:
    vmid: 900
    node: pve0
    api_user: "{{ api_usr }}@pam"
    api_password: "{{ api_passwd }}"
    api_host: pve0
    password: "{{ container_passwd }}"
    hostname: test
#    ostemplate: 'data:vztmpl/rockylinux-9-default_20221109_amd64.tar.xz'
    ostemplate: "{{ os_template }}"
    storage: "{{ s_location }}"
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!