32 lines
942 B
YAML
32 lines
942 B
YAML
---
|
|
- 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 |