Sincerely, if someone can indicate what is wrong with this ...
The following code is for installing a test in a register module that prints the current value /etc/timezone. Then a task is executed that compares this with the group / host {{timezone}} variable and runs the task only if it is different (that is, it does not call handlers unnecessarily).
But it always works independently.
- name: check current timezone
shell: cat /etc/timezone
register: get_timezone
- name: set /etc/timezone
shell: echo "{{ timezone }}" > /etc/timezone
when: get_timezone.stdout.find('{{ timezone }}') == false
notify: update tzdata
....
in group_vars / all.yml:
timezone: Europe/London
source
share