Update file main.yml

This commit is contained in:
Administrator 2025-10-10 15:59:39 +00:00
parent 51c882a2af
commit 66dcbe6c3a

View File

@ -1,20 +1,32 @@
---
- name: Create Gateway LXC container
community.proxmox.proxmox_lxc:
node: "{{ proxmox_node }}"
vmid: 221
hostname: gateway
storage: "vmsystem"
cores: 1
memory: 2048
swap: 512
rootfs: "vmsystem:5"
template: "ubuntu-24.04-standard_24.04-2_amd64.tar.zst"
password: "{{ proxmox_root_password }}"
net:
name: eth0
bridge: vmbr0
ip: 192.168.1.221/24
gw: 192.168.1.1
unprivileged: true
state: present
- name: Check if container already exists
shell: pct list | grep 221 || true
register: container_check
delegate_to: "{{ groups['proxmox_servers'][0] }}"
changed_when: false
- name: Create Gateway LXC container using pct command
shell: |
pct create 221 \
/var/lib/vz/template/cache/ubuntu-24.04-standard_24.04-2_amd64.tar.zst \
--rootfs vmsystem:5 \
--cores 1 \
--memory 2048 \
--swap 512 \
--hostname gateway \
--net0 name=eth0,bridge=vmbr0,ip=192.168.1.221/24,gw=192.168.1.1 \
--storage vmsystem \
--password {{ proxmox_root_password }} \
--unprivileged 1 \
--start 1
args:
executable: /bin/bash
delegate_to: "{{ groups['proxmox_servers'][0] }}"
when: "'221' not in container_check.stdout"
- name: Wait for container to start
wait_for_connection:
host: 192.168.1.221
port: 22
timeout: 60
delay: 5