From a529b84a3c5af55e2968f70c8a019eb441b524c4 Mon Sep 17 00:00:00 2001 From: Maksym Buz Date: Sun, 4 Jan 2026 11:13:48 +0100 Subject: [PATCH] feat: Allow specifying container ID during LXC creation, ensure explicit start, and update README with `proxmoxer` dependency. --- README.md | 3 ++- playbooks/create_lxc.yml | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d994d7..0c823d7 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,9 @@ This Ansible setup is designed to automate the configuration and maintenance of To use the provisioning playbooks (`create_lxc.yml`), you must configure Proxmox API access. ### 1. Requirements on Control Node -Install `community.general` collection: +Install `community.general` collection and `proxmoxer` python library: ```bash +sudo apt install python3-proxmoxer # OR pip3 install proxmoxer requests ansible-galaxy collection install community.general ``` diff --git a/playbooks/create_lxc.yml b/playbooks/create_lxc.yml index 22becfa..3e0191d 100644 --- a/playbooks/create_lxc.yml +++ b/playbooks/create_lxc.yml @@ -11,6 +11,9 @@ - name: container_ip prompt: "Enter the IP address (CIDR format preferred, or I will append /24) e.g., 10.0.0.123" private: no + - name: container_id + prompt: "Enter the Container ID (VMID) e.g., 105" + private: no tasks: - name: Normalize IP address (append /24 if missing) @@ -26,6 +29,7 @@ node: "{{ proxmox_node }}" storage: "{{ proxmox_storage }}" ostemplate: '{{ proxmox_storage }}:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst' + vmid: "{{ container_id }}" hostname: "{{ container_name }}" password: "TempPassword123!" # Temporary password, will be disabled by lxc_setup netif: @@ -33,12 +37,21 @@ cores: 2 memory: 1024 swap: 512 - state: started + state: present unprivileged: yes features: - nesting=1 register: proxmox_creation + - name: Start the container + community.general.proxmox: + api_host: "{{ proxmox_host | default('10.0.0.1') }}" + api_user: "{{ proxmox_api_user }}" + api_token_id: "{{ proxmox_api_token_id }}" + api_token_secret: "{{ proxmox_api_token_secret }}" + vmid: "{{ container_id }}" + state: started + - name: Wait for container to be reachable wait_for: host: "{{ container_ip_cidr | split('/') | first }}"