chore 📦: Update setupacdc.yml to improve container provisioning and cleanup processes

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.
This commit is contained in:
2025-11-02 16:59:48 +01:00
parent a71d196cc0
commit 98bf9f3c25

View File

@@ -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
# --- DC1 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