feat: Make LXC CPU cores and memory configurable during creation and refine inventory group insertion regex.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user