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