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
This commit is contained in:
2025-12-02 23:09:46 +01:00
parent 46174125bc
commit 94f97ed1f3
13 changed files with 21 additions and 21 deletions

View File

@@ -28,5 +28,5 @@ transfer_method = smart
connect_timeout = 30
command_timeout = 60
[callback_default]
result_format = yaml
#[callback_default]
#result_format = yaml

View File

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

View File

@@ -1,4 +1,4 @@
- name: "Execute {{ SOFTWARE_NAME }} Play"
- name: "Execute Infinito.Nexus Play"
hosts: all
tasks:
- name: "Load 'constructor' tasks"

View File

@@ -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:

View File

@@ -2,4 +2,4 @@
application_id: "desk-chromium"
chromium_package: "{{ 'chromium-browser' if ansible_os_family == 'Debian' else 'chromium' }}"
chromium_package: "{{ 'chromium-browser' if ansible_facts['os_family'] == 'Debian' else 'chromium' }}"

View File

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

View File

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

View File

@@ -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 }}"

View File

@@ -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:

View File

@@ -1 +1 @@
swapfile_size: "{{ ansible_memtotal_mb | int }}M"
swapfile_size: "{{ ansible_facts['memtotal_mb'] | int }}M"

View File

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

View File

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

View File

@@ -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: