From a71d196cc0bfc5b31ac84e82626ef6a29e296c12 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 2 Nov 2025 12:36:17 +0100 Subject: [PATCH] =?UTF-8?q?chore=20=F0=9F=93=A6:=20Update=20LXC=20containe?= =?UTF-8?q?r=20management=20in=20setupacdc.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the Ansible playbook to check if a LXC container is running before starting it, and added a conditional statement to start the container only when it's stopped. This change improves the reliability of the setup process. --- tasks/setupacdc.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tasks/setupacdc.yml b/tasks/setupacdc.yml index cc082cd..17c35c0 100644 --- a/tasks/setupacdc.yml +++ b/tasks/setupacdc.yml @@ -66,11 +66,18 @@ # -timezone: {{ localization_timezone }} \ - - name: Start the LXC container {{ container_hostname }} + - name: Check if LXC container {{ container_hostname }} is running + ansible.builtin.command: + cmd: pct status {{ container_id }} + register: pct_status + changed_when: false + + - name: Start the LXC container {{ container_hostname }} if stopped ansible.builtin.command: cmd: pct start {{ container_id }} + when: "'status: stopped' in pct_status.stdout" register: start_result - changed_when: "'started' in start_result.stdout or start_result.rc == 0" + changed_when: "'status: stopped' in pct_status.stdout" - name: Wait until container has an IP address ansible.builtin.shell: "pct exec {{ container_id }} -- hostname -I | awk '{print $1}'"