From 98bf9f3c25bd58934160a88d45dcecc61291f21b Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 2 Nov 2025 16:59:48 +0100 Subject: [PATCH] =?UTF-8?q?chore=20=F0=9F=93=A6:=20Update=20setupacdc.yml?= =?UTF-8?q?=20to=20improve=20container=20provisioning=20and=20cleanup=20pr?= =?UTF-8?q?ocesses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the setupacdc.yml configuration to include additional checks for container IP address availability, improved package management, and enhanced timezone handling. These changes aim to streamline the provisioning process while maintaining a clean and efficient environment. --- tasks/setupacdc.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tasks/setupacdc.yml b/tasks/setupacdc.yml index 17c35c0..5477c2e 100644 --- a/tasks/setupacdc.yml +++ b/tasks/setupacdc.yml @@ -61,6 +61,7 @@ -features {{ container_features }} args: creates: "/etc/pve/lxc/{{ container_id }}.conf" + no_log: true # -rootfs {{ container_storage }}:{{ container_id }}/vm-{{ container_id }}-disk-0.raw,size=7G \ @@ -80,12 +81,13 @@ 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}'" + ansible.builtin.command: "pct exec {{ container_id }} -- hostname -I | awk '{print $1}'" register: lxc_ip until: lxc_ip.stdout != "" retries: 10 delay: 5 changed_when: false + failed_when: lxc_ip.stdout == "" - name: Wait for SSH to become available ansible.builtin.wait_for: @@ -93,6 +95,11 @@ port: 22 delay: 5 timeout: 60 + retries: 10 + delay: 5 + changed_when: false + +# --- DC‑1 Provisioning Play -------------------------------------------- - name: Provision dc1 LXC hosts: dc1 @@ -117,20 +124,25 @@ # - openssh-server state: present - - name: Update all packages to their latest version + - name: Update all packages, autoclean, and autoremove ansible.builtin.apt: name: "*" state: latest - - - name: Remove useless packages from the cache - ansible.builtin.apt: autoclean: yes - - - name: Remove dependencies that are no longer required and purge their configuration files - ansible.builtin.apt: autoremove: yes purge: true - name: Set timezone to {{ localization_timezone }} community.general.timezone: name: "{{ localization_timezone }}" + notify: Restart sshd + tags: [timezone] + +# --- Global Handlers ---------------------------------------------- + + handlers: + - name: Restart sshd + ansible.builtin.service: + name: ssh + state: restarted + when: localization_timezone | bool \ No newline at end of file