Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/timezone/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 ##
12 ## set path to timezone config files
13 ##
14
15 - name: set config file path on Debian
16 set_fact:
17 timezone_config_file: '/etc/timezone'
18 when: ansible_facts.os_family == 'Debian'
19
20 - name: set config file path on RedHat
21 set_fact:
22 timezone_config_file: '/etc/sysconfig/clock'
23 when: ansible_facts.os_family == 'RedHat'
24
25 ##
26 ## set path to hwclock config files
27 ##
28
29 - name: set config file path on Debian
30 set_fact:
31 hwclock_config_file: '/etc/default/rcS'
32 when: ansible_facts.os_family == 'Debian'
33
34 - name: set config file path on RedHat
35 set_fact:
36 hwclock_config_file: '/etc/sysconfig/clock'
37 when: ansible_facts.os_family == 'RedHat'
38
39 ####
40 #### timezone tests
41 ####
42
43 - name: make sure diffutils are installed on ArchLinux
44 package:
45 name: diffutils
46 state: present
47 when: ansible_facts.distribution == 'Archlinux'
48
49 - name: make sure util-linux-extra are installed on Debian 13+
50 package:
51 name: util-linux-extra
52 state: present
53 when: ansible_facts.distribution == 'Debian' and ansible_facts.distribution_major_version|int >= 13
54
55 - name: make sure tzdata is installed on Alpine
56 package:
57 name: tzdata
58 state: present
59 when: ansible_facts.distribution == 'Alpine'
60
61 - name: make sure hwclock is installed in Ubuntu 24.04
62 package:
63 name: util-linux-extra
64 state: present
65 when:
66 - ansible_facts.distribution == 'Ubuntu'
67 - ansible_facts.distribution_major_version is version('24', '>=')
68
69
70 - name: Run tests
71 when:
72 - not (ansible_facts.os_family == 'Alpine') # TODO
73 - not (ansible_facts.distribution == 'Archlinux') # TODO
74 block:
75 - name: set timezone to Etc/UTC
76 timezone:
77 name: Etc/UTC
78 register: original_timezone
79
80 - name: Value of original_timezone
81 debug:
82 msg: "{{ original_timezone }}"
83
84 - block:
85 - include_tasks: test.yml
86 always:
87 - name: Restore original system timezone - {{ original_timezone.diff.before.name }}
88 timezone:
89 name: "{{ original_timezone.diff.before.name }}"
90 when: original_timezone is changed and original_timezone.diff.before.name != 'n/a'