From 94f97ed1f30d6e0e1cfac9a9708c83d6331604ff Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 2 Dec 2025 23:09:46 +0100 Subject: [PATCH] Refactor: Migrate deprecated Ansible facts to ansible_facts[] syntax Why: - Ansible 2.20+ deprecates INJECT_FACTS_AS_VARS and direct usage of top-level ansible_* facts. - This change updates all affected roles and vars files to the new supported syntax. - Ensures compatibility with upcoming Ansible 2.24 removal of implicit fact injection. Conversation reference: https://chatgpt.com/share/692f639b-1380-800f-9f18-732f7108e9e2 --- ansible.cfg | 4 ++-- group_vars/all/18_resource.yml | 4 ++-- playbook.yml | 2 +- roles/desk-chromium/tasks/main.yml | 2 +- roles/desk-chromium/vars/main.yml | 2 +- roles/desk-copyq/tasks/main.yml | 4 ++-- roles/desk-copyq/tasks/server.yml | 4 ++-- roles/svc-db-postgres/vars/main.yml | 4 ++-- roles/svc-net-wireguard-core/tasks/main.yml | 4 ++-- roles/svc-opt-swapfile/config/main.yml | 2 +- roles/sys-svc-sshd/templates/sshd_config.j2 | 2 +- roles/update-compose/tasks/01_core.yml | 4 ++-- roles/web-app-nextcloud/config/main.yml | 4 ++-- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ansible.cfg b/ansible.cfg index 3c51d1b9..2de14700 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -28,5 +28,5 @@ transfer_method = smart connect_timeout = 30 command_timeout = 60 -[callback_default] -result_format = yaml \ No newline at end of file +#[callback_default] +#result_format = yaml \ No newline at end of file diff --git a/group_vars/all/18_resource.yml b/group_vars/all/18_resource.yml index 329d3b34..8d654197 100644 --- a/group_vars/all/18_resource.yml +++ b/group_vars/all/18_resource.yml @@ -1,6 +1,6 @@ # Host resources -RESOURCE_HOST_CPUS: "{{ ansible_processor_vcpus | int }}" -RESOURCE_HOST_MEM: "{{ (ansible_memtotal_mb | int) // 1024 }}" +RESOURCE_HOST_CPUS: "{{ ansible_facts['processor_vcpus'] | int }}" +RESOURCE_HOST_MEM: "{{ (ansible_facts['memtotal_mb'] | int) // 1024 }}" # Reserve for OS RESOURCE_HOST_RESERVE_CPU: 2 diff --git a/playbook.yml b/playbook.yml index bf10da0b..2bb334ee 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,4 +1,4 @@ -- name: "Execute {{ SOFTWARE_NAME }} Play" +- name: "Execute Infinito.Nexus Play" hosts: all tasks: - name: "Load 'constructor' tasks" diff --git a/roles/desk-chromium/tasks/main.yml b/roles/desk-chromium/tasks/main.yml index 58877844..98ebd892 100644 --- a/roles/desk-chromium/tasks/main.yml +++ b/roles/desk-chromium/tasks/main.yml @@ -2,7 +2,7 @@ - name: Update package cache (Debian/Ubuntu) apt: update_cache: yes - when: ansible_os_family == "Debian" + when: ansible_facts['os_family'] == "Debian" - name: Install Chromium browser package: diff --git a/roles/desk-chromium/vars/main.yml b/roles/desk-chromium/vars/main.yml index 9efb57c0..b9276885 100644 --- a/roles/desk-chromium/vars/main.yml +++ b/roles/desk-chromium/vars/main.yml @@ -2,4 +2,4 @@ application_id: "desk-chromium" -chromium_package: "{{ 'chromium-browser' if ansible_os_family == 'Debian' else 'chromium' }}" \ No newline at end of file +chromium_package: "{{ 'chromium-browser' if ansible_facts['os_family'] == 'Debian' else 'chromium' }}" \ No newline at end of file diff --git a/roles/desk-copyq/tasks/main.yml b/roles/desk-copyq/tasks/main.yml index 6755d38e..e2e1a075 100644 --- a/roles/desk-copyq/tasks/main.yml +++ b/roles/desk-copyq/tasks/main.yml @@ -5,14 +5,14 @@ - name: Ensure autostart directory exists file: - path: "{{ ansible_env.HOME }}/.config/autostart" + path: "{{ ansible_facts['env']['HOME'] }}/.config/autostart" state: directory mode: '0755' become: false - name: Add CopyQ to user autostart copy: - dest: "{{ ansible_env.HOME }}/.config/autostart/copyq.desktop" + dest: "{{ ansible_facts['env']['HOME'] }}/.config/autostart/copyq.desktop" content: | [Desktop Entry] Type=Application diff --git a/roles/desk-copyq/tasks/server.yml b/roles/desk-copyq/tasks/server.yml index 0de99188..4c61eb7c 100644 --- a/roles/desk-copyq/tasks/server.yml +++ b/roles/desk-copyq/tasks/server.yml @@ -1,13 +1,13 @@ - name: Ensure systemd user unit directory exists file: - path: "{{ ansible_env.HOME }}/.config/systemd/user" + path: "{{ ansible_facts['env']['HOME'] }}/.config/systemd/user" state: directory mode: '0755' become: false - name: Install CopyQ user service unit copy: - dest: "{{ ansible_env.HOME }}/.config/systemd/user/copyq.service" + dest: "{{ ansible_facts['env']['HOME'] }}/.config/systemd/user/copyq.service" content: | [Unit] Description=CopyQ Clipboard Manager Server diff --git a/roles/svc-db-postgres/vars/main.yml b/roles/svc-db-postgres/vars/main.yml index e703b48a..cbe7508a 100644 --- a/roles/svc-db-postgres/vars/main.yml +++ b/roles/svc-db-postgres/vars/main.yml @@ -25,8 +25,8 @@ POSTGRES_VECTOR_ENABLED: True # Required by discourse, propably POSTGRES_RETRIES: 5 ## Performance -POSTGRES_TOTAL_RAM_MB: "{{ ansible_memtotal_mb | int }}" -POSTGRES_VCPUS: "{{ ansible_processor_vcpus | int }}" +POSTGRES_TOTAL_RAM_MB: "{{ ansible_facts['memtotal_mb'] | int }}" +POSTGRES_VCPUS: "{{ ansible_facts['processor_vcpus'] | int }}" POSTGRES_MAX_CONNECTIONS: "{{ [ ((POSTGRES_VCPUS | int) * 30 + 50), 400 ] | min }}" POSTGRES_SUPERUSER_RESERVED_CONNECTIONS: 3 POSTGRES_SHARED_BUFFERS_MB: "{{ ((POSTGRES_TOTAL_RAM_MB | int) * 25) // 100 }}" diff --git a/roles/svc-net-wireguard-core/tasks/main.yml b/roles/svc-net-wireguard-core/tasks/main.yml index 1e974549..da797553 100644 --- a/roles/svc-net-wireguard-core/tasks/main.yml +++ b/roles/svc-net-wireguard-core/tasks/main.yml @@ -2,13 +2,13 @@ community.general.pacman: name: wireguard-tools state: present - when: ansible_os_family == "Archlinux" + when: ansible_facts['os_family'] == "Archlinux" - name: install wireguard for Ubuntu apt: name: wireguard state: present - when: ansible_os_family == "Debian" + when: ansible_facts['os_family'] == "Debian" - name: create wireguard-ip.conf copy: diff --git a/roles/svc-opt-swapfile/config/main.yml b/roles/svc-opt-swapfile/config/main.yml index 022867e7..7577e9e2 100644 --- a/roles/svc-opt-swapfile/config/main.yml +++ b/roles/svc-opt-swapfile/config/main.yml @@ -1 +1 @@ -swapfile_size: "{{ ansible_memtotal_mb | int }}M" \ No newline at end of file +swapfile_size: "{{ ansible_facts['memtotal_mb'] | int }}M" \ No newline at end of file diff --git a/roles/sys-svc-sshd/templates/sshd_config.j2 b/roles/sys-svc-sshd/templates/sshd_config.j2 index 0a975345..83848db1 100644 --- a/roles/sys-svc-sshd/templates/sshd_config.j2 +++ b/roles/sys-svc-sshd/templates/sshd_config.j2 @@ -119,7 +119,7 @@ UseDNS no #Banner none # override default of no subsystems -{% if ansible_os_family == "Archlinux" %} +{% if ansible_facts['os_family'] == "Archlinux" %} Subsystem sftp /usr/lib/ssh/sftp-server {% else%} Subsystem sftp /usr/lib/openssh/sftp-server diff --git a/roles/update-compose/tasks/01_core.yml b/roles/update-compose/tasks/01_core.yml index 1254253d..ac067acc 100644 --- a/roles/update-compose/tasks/01_core.yml +++ b/roles/update-compose/tasks/01_core.yml @@ -8,14 +8,14 @@ include_role: name: update-pacman when: - - ansible_distribution == 'Archlinux' + - ansible_facts['distribution'] == 'Archlinux' - run_once_update_pacman is not defined - name: "Update with apt" include_role: name: update-apt when: - - ansible_distribution == "Debian" + - ansible_facts['distribution'] == "Debian" - run_once_update_apt is not defined - include_tasks: utils/once_finalize.yml \ No newline at end of file diff --git a/roles/web-app-nextcloud/config/main.yml b/roles/web-app-nextcloud/config/main.yml index db1bb419..92c488c7 100644 --- a/roles/web-app-nextcloud/config/main.yml +++ b/roles/web-app-nextcloud/config/main.yml @@ -134,9 +134,9 @@ legacy_login_mask: performance: php: - memory_limit: "{{ ((ansible_memtotal_mb | int) / 30)|int }}M" # Dynamic set memory limit + memory_limit: "{{ ((ansible_facts['memtotal_mb'] | int) / 30)|int }}M" # Dynamic set memory limit upload_limit: "5G" # Set upload limit to 5GB for big media files - opcache_memory_consumption: "{{ ((ansible_memtotal_mb | int) / 30)|int }}M" # Dynamic set memory consumption + opcache_memory_consumption: "{{ ((ansible_facts['memtotal_mb'] | int) / 30)|int }}M" # Dynamic set memory consumption plugins_enabled: true # Implemented for speeding up testing and debugging process. For productive environments keep it true and steer the apps via the plugins config oidc: