---
# tasks file for ansible_common

- name: Assert
  assert:
    that: ansible_os_family in [ 'Debian', 'OpenBSD' ]

- include: init.yml
  when: ansible_os_family == 'Debian' and not common_role_finished is defined

- include: backports.yml
  when: backports|default(False) and ansible_os_family == 'Debian' and not common_role_finished is defined

- include: add_repo.yml
  when: ansible_distribution == 'Debian' and extra_repos is defined and not common_role_finished is defined

- include: ufw.yml
  when: ufw|default(True) and ansible_os_family == 'Debian' and not common_role_finished is defined

- include: tls_cert.yml
  when: tls_cert|default(True) and not common_role_finished is defined

- include: add_tls_cert.yml
  when: not common_role_finished is defined

- include: ssh_ca.yml
  when: ssh_ca|default(True) and not common_role_finished is defined

- include: syslog_forward.yml
  when: syslog_server is defined and not common_role_finished is defined

- include: collectd_agent.yml
  when: (collectd_graphite_server is defined or collectd_riemann_server is defined or collectd_collectd_server is defined or collectd_statsd_server is defined) and not common_role_finished is defined

- include: mail_forward.yml
  when: mail_root_alias is defined and not common_role_finished is defined

- include: ldap_login.yml
  when: ldap_login_server is defined and not common_role_finished is defined

- include: sudo.yml
  when: sudo|default(True) and not common_role_finished is defined

- include: ntp.yml
  when: ntp|default(True) and not common_role_finished is defined

- include: unattended_upgrades.yml
  when: unattended_upgrades|default(True) and ansible_os_family == 'Debian' and not common_role_finished is defined

- include: lock_root.yml
  when: lock_root|default(True) and not common_role_finished is defined

- set_fact:
    common_role_finished: True
