feat: Make LXC CPU cores and memory configurable during creation and refine inventory group insertion regex.

This commit is contained in:
2026-01-04 11:28:13 +01:00
parent 03dedfda68
commit 9e0ba359ec
2 changed files with 11 additions and 3 deletions

View File

@@ -15,6 +15,14 @@
- name: container_id - name: container_id
prompt: "Enter the Container ID (VMID) e.g., 105" prompt: "Enter the Container ID (VMID) e.g., 105"
private: no private: no
- name: container_cores
prompt: "Enter CPU Cores (e.g., 2)"
default: "2"
private: no
- name: container_memory
prompt: "Enter Memory in MB (e.g., 1024)"
default: "256"
private: no
tasks: tasks:
- name: Normalize IP address (append /24 if missing) - name: Normalize IP address (append /24 if missing)
@@ -36,8 +44,8 @@
password: "{{ ansible_password }}" password: "{{ ansible_password }}"
netif: netif:
net0: "name=eth0,gw=10.0.0.1,ip={{ container_ip_cidr }},bridge=vmbr0" net0: "name=eth0,gw=10.0.0.1,ip={{ container_ip_cidr }},bridge=vmbr0"
cores: 2 cores: "{{ container_cores }}"
memory: 1024 memory: "{{ container_memory }}"
swap: 512 swap: 512
state: present state: present
unprivileged: yes unprivileged: yes

View File

@@ -76,6 +76,6 @@
path: /opt/ansible/inventory/hosts.ini path: /opt/ansible/inventory/hosts.ini
block: | block: |
{{ item }} ansible_host={{ hostvars[item]['ansible_host'] }} {{ item }} ansible_host={{ hostvars[item]['ansible_host'] }}
insertafter: "[lxc]" insertafter: "^\\[lxc\\]"
marker: "# {mark} ANSIBLE MANAGED BLOCK FOR LXC" marker: "# {mark} ANSIBLE MANAGED BLOCK FOR LXC"
loop: "{{ groups['new'] }}" # Loop over all hosts in the 'new' group loop: "{{ groups['new'] }}" # Loop over all hosts in the 'new' group