--- - hosts: core, dvrs, tvrs, webtvs tasks: - name: Update timezone. become: yes command: timedatectl set-timezone {{ city }} when: ansible_date_time.tz != zone register: new_tz - hosts: dvrs tasks: - name: Restart AgentDVR. become: yes systemd: service: AgentDVR state: restarted when: new_tz.changed - hosts: tvrs tasks: - name: Restart MythTV. become: yes systemd: service: "{{ item }}" state: restarted loop: [ mysql, mythtv-backend ] when: new_tz.changed - hosts: core tasks: - name: Update PHP date.timezone. become: yes lineinfile: regexp: date.timezone ?= line: date.timezone = {{ city }} path: "{{ item }}" loop: - /etc/php/8.2/cli/php.ini - /etc/php/8.2/apache2/php.ini notify: Restart Apache2. handlers: - name: Restart Apache2. become: yes systemd: service: apache2 state: restarted