Update: Replace deprecated ansible_os_family with ansible_facts.os_family

- x2go-server.yml: Updated condition to use ansible_facts.os_family
- upgrade.yml: Updated all conditions and commented lines
- caching-nameserver.yml: Updated RedHat OS family checks

Fixes deprecation warning in Ansible 2.12+
This commit is contained in:
2026-03-10 11:09:25 +01:00
parent 94d7f4e1fb
commit 055290e555
3 changed files with 11 additions and 10 deletions

View File

@@ -60,7 +60,7 @@
update_cache: yes update_cache: yes
#cache_valid_time: 3600 #cache_valid_time: 3600
when: when:
- ansible_os_family == "RedHat" - ansible_facts.os_family == "RedHat"
- ansible_facts["distribution"] == "CentOS" - ansible_facts["distribution"] == "CentOS"
tags: tags:
- yum-update - yum-update
@@ -70,7 +70,7 @@
name: "{{ yum_bind_pks }}" name: "{{ yum_bind_pks }}"
state: "{{ yum_install_state }}" state: "{{ yum_install_state }}"
when: when:
- ansible_os_family == "RedHat" - ansible_facts.os_family == "RedHat"
- ansible_facts["distribution"] == "CentOS" - ansible_facts["distribution"] == "CentOS"
tags: tags:
- yum-caching-nameserver - yum-caching-nameserver

View File

@@ -9,10 +9,11 @@
name: name:
- x2goserver - x2goserver
- x2goserver-xsession - x2goserver-xsession
- x2gobroker-daemon - x2goserver-printing
- cups-x2go
state: present state: present
when: when:
- ansible_os_family == "Debian" - ansible_facts.os_family == "Debian"
- "groups['x2go_server']|string is search(inventory_hostname)" - "groups['x2go_server']|string is search(inventory_hostname)"
tags: tags:
- x2g--server - x2g--server

View File

@@ -6,21 +6,21 @@
- name: Update packages list - name: Update packages list
apt: update_cache=yes apt: update_cache=yes
when: ansible_os_family == 'Debian' when: ansible_facts.os_family == 'Debian'
- name: List packages to upgrade (1/2) - name: List packages to upgrade (1/2)
shell: aptitude -q -F%p --disable-columns search "~U" shell: aptitude -q -F%p --disable-columns search "~U"
register: updates register: updates
changed_when: False changed_when: False
when: ansible_os_family == 'Debian' when: ansible_facts.os_family == 'Debian'
- name: List packages to upgrade (2/2) - name: List packages to upgrade (2/2)
debug: msg="{{ updates.stdout_lines | count }} packages to upgrade ({{ updates.stdout_lines | join(', ') }})" debug: msg="{{ updates.stdout_lines | count }} packages to upgrade ({{ updates.stdout_lines | join(', ') }})"
when: (ansible_os_family == 'Debian' and updates.stdout_lines) when: (ansible_facts.os_family == 'Debian' and updates.stdout_lines)
- name: Upgrade packages - name: Upgrade packages
apt: upgrade=safe apt: upgrade=safe
when: ansible_os_family == 'Debian' when: ansible_facts.os_family == 'Debian'
- name: Check what the new version is - name: Check what the new version is
shell: lsb_release -r | awk '{print $2}' shell: lsb_release -r | awk '{print $2}'
@@ -43,11 +43,11 @@
# - name: list services to restart (3/3) # - name: list services to restart (3/3)
# debug: msg="{{ services.stdout_lines | count }} services to restart ({{ services.stdout_lines | join (", ") }})" # debug: msg="{{ services.stdout_lines | count }} services to restart ({{ services.stdout_lines | join (", ") }})"
# when: (ansible_os_family == 'Debian' and services.stdout_lines) # when: (ansible_facts.os_family == 'Debian' and services.stdout_lines)
# - name: list services to restart (2/3) # - name: list services to restart (2/3)
# debug: msg="{{ services.stdout_lines | count }} services to restart ({{ services.stdout_lines | join (", ") }})" # debug: msg="{{ services.stdout_lines | count }} services to restart ({{ services.stdout_lines | join (", ") }})"
# when: (ansible_os_family == 'Debian' and services.stdout_lines) # when: (ansible_facts.os_family == 'Debian' and services.stdout_lines)
- name: cache cleanup - name: cache cleanup
shell: apt-get autoclean shell: apt-get autoclean