---

- name: Update timezone
  command: dpkg-reconfigure --frontend noninteractive tzdata

#- name: Restart ssh
#  shell: sleep 3; systemctl restart sshd
#  async: 1
#  poll: 0

# Does NOT Work
#
# Error was:
#    Start request repeated too quickly.
#
# See also: https://github.com/ansible/ansible-modules-core/issues/1533
# 
- name: Restart ssh
  service:
    name: ssh
    state: restarted

- name: Reload nfs
  service:
    name: nfs-kernel-server
    state: reloaded
    enabled: yes
  when:
    - "groups['nfs_server']|string is search(inventory_hostname)"

- name: Restart postfix
  service:
    name: postfix
    state: restarted

- name: Reload bind9
  service:
    name: bind9
    state: reloaded
    enabled: yes


- name: Restart smbd
  service:
    name: smbd
    daemon_reload: yes
    state: restarted

- name: Restart nmbd
  service:
    name: nmbd
    daemon_reload: yes
    state: restarted

- name: Reload samba config
  shell: smbcontrol all reload-config
  when:
    - inventory_hostname in groups['samba_server']

- name: Restart systemd-journald
  service:
    name: systemd-journald
    state: restarted

- name: Restart redis-server
  vars:
    _daemon: "{{ 'redis' if ansible_facts['distribution'] == 'CentOS' else 'redis-server' }}"
  service:
    name: "{{ _daemon }}"
    state: restarted

- name: Restart tor service
  service: 
    name: tor
    state: restarted

- name: Reload tor service
  service:
    name: tor
    state: reloaded

- name: Reload postfwd
  service:
    name: postfwd
    state: reloaded

- name: Restart systemd-resolved
  service:
    name: systemd-resolved
    state: restarted

- name: Restart nfs-kernel-server
  service:
    name: nfs-kernel-server
    state: restarted

- name: Restart ntp
  service:
    name: ntpsec
    daemon_reload: yes
    state: restarted

- name: Restart mariadb
  service:
    name: mariadb
    daemon_reload: yes
    state: restarted

- name: Restart apache2
  service:
    name: apache2
    daemon_reload: yes
    state: restarted

- name: Reload AppArmor profile clamd
  command: apparmor_parser -r /etc/apparmor.d/usr.sbin.clamd

- name: Restart clamav-daemon
  service:
    name: clamav-daemon
    state: restarted
