1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-18 09:51:41 +00:00
community.general/tests/integration/targets/timezone/tasks/main.yml
Alexei Znamensky 79431c36b5
integration tests: remove CentOS conditionals (#11715)
* test(integration): remove CentOS references

* further simplification

* more removals

* rollback systemd_info for now

* ufw: not trivially used with RHEL9 and RHEL10, simplifying tests

* remove tasks for setup_epel where unused

* adjustments from review
2026-04-03 07:37:05 +02:00

90 lines
2.5 KiB
YAML

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
##
## set path to timezone config files
##
- name: set config file path on Debian
set_fact:
timezone_config_file: '/etc/timezone'
when: ansible_facts.os_family == 'Debian'
- name: set config file path on RedHat
set_fact:
timezone_config_file: '/etc/sysconfig/clock'
when: ansible_facts.os_family == 'RedHat'
##
## set path to hwclock config files
##
- name: set config file path on Debian
set_fact:
hwclock_config_file: '/etc/default/rcS'
when: ansible_facts.os_family == 'Debian'
- name: set config file path on RedHat
set_fact:
hwclock_config_file: '/etc/sysconfig/clock'
when: ansible_facts.os_family == 'RedHat'
####
#### timezone tests
####
- name: make sure diffutils are installed on ArchLinux
package:
name: diffutils
state: present
when: ansible_facts.distribution == 'Archlinux'
- name: make sure util-linux-extra are installed on Debian 13+
package:
name: util-linux-extra
state: present
when: ansible_facts.distribution == 'Debian' and ansible_facts.distribution_major_version|int >= 13
- name: make sure tzdata is installed on Alpine
package:
name: tzdata
state: present
when: ansible_facts.distribution == 'Alpine'
- name: make sure hwclock is installed in Ubuntu 24.04
package:
name: util-linux-extra
state: present
when:
- ansible_facts.distribution == 'Ubuntu'
- ansible_facts.distribution_major_version is version('24', '>=')
- name: Run tests
when:
- not (ansible_facts.os_family == 'Alpine') # TODO
- not (ansible_facts.distribution == 'Archlinux') # TODO
block:
- name: set timezone to Etc/UTC
timezone:
name: Etc/UTC
register: original_timezone
- name: Value of original_timezone
debug:
msg: "{{ original_timezone }}"
- block:
- include_tasks: test.yml
always:
- name: Restore original system timezone - {{ original_timezone.diff.before.name }}
timezone:
name: "{{ original_timezone.diff.before.name }}"
when: original_timezone is changed and original_timezone.diff.before.name != 'n/a'