diff --git a/roles/debian-base/tasks/relayhost.yml b/roles/debian-base/tasks/relayhost.yml index dc04fe1..f912812 100644 --- a/roles/debian-base/tasks/relayhost.yml +++ b/roles/debian-base/tasks/relayhost.yml @@ -1,29 +1,33 @@ -- name: Install exim packages - apt: - name: exim4 - state: present -- name: Prepare exim configuration - blockinfile: - path: /etc/exim4/update-exim4.conf.conf - marker_begin: '--- BEGIN VN ---' - marker_end: '--- END VN ---' - marker: "# {mark}" - block: | - dc_eximconfig_configtype='satellite' - dc_other_hostnames='{{ ansible_fqdn }}' - dc_local_interfaces='127.0.0.1' - dc_readhost='{{ ansible_fqdn }}' - dc_smarthost='{{ smtp_server }}' - dc_hide_mailname='true' - state: present - create: yes - mode: u=rw,g=r,o=r - notify: update exim configuration - register: exim_config -- name: Force execution of handlers immediately - meta: flush_handlers -- name: Sending mail to verify relay host configuration works - shell: > - sleep 2; echo "If you see this message, relayhost on {{ ansible_fqdn }} has been configured correctly." \ - | mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ sysadmin_mail }}" - when: exim_config.changed +- name: Getting service facts to check for postfix + service_facts: +- when: "'postfix.service' not in ansible_facts.services" + block: + - name: Install exim packages + apt: + name: exim4 + state: present + - name: Prepare exim configuration + blockinfile: + path: /etc/exim4/update-exim4.conf.conf + marker_begin: '--- BEGIN VN ---' + marker_end: '--- END VN ---' + marker: "# {mark}" + block: | + dc_eximconfig_configtype='satellite' + dc_other_hostnames='{{ ansible_fqdn }}' + dc_local_interfaces='127.0.0.1' + dc_readhost='{{ ansible_fqdn }}' + dc_smarthost='{{ smtp_server }}' + dc_hide_mailname='true' + state: present + create: yes + mode: u=rw,g=r,o=r + notify: update exim configuration + register: exim_config + - name: Force execution of handlers immediately + meta: flush_handlers + - name: Sending mail to verify relay host configuration works + shell: > + sleep 2; echo "If you see this message, relayhost on {{ ansible_fqdn }} has been configured correctly." \ + | mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ sysadmin_mail }}" + when: exim_config.changed diff --git a/roles/debian-host/tasks/apparmor.yml b/roles/debian-host/tasks/apparmor.yml index a239254..887d95f 100644 --- a/roles/debian-host/tasks/apparmor.yml +++ b/roles/debian-host/tasks/apparmor.yml @@ -1,12 +1,16 @@ -- name: Stop AppArmor - systemd: - name: apparmor - state: stopped -- name: Disable AppArmor service - systemd: - name: apparmor - enabled: no -- name: Mask AppArmor service - systemd: - name: apparmor - masked: yes \ No newline at end of file +- name: Getting service facts to check for apparmor + service_facts: +- when: "'apparmor.service' in ansible_facts.services" + block: + - name: Stop AppArmor + systemd: + name: apparmor + state: stopped + - name: Disable AppArmor service + systemd: + name: apparmor + enabled: no + - name: Mask AppArmor service + systemd: + name: apparmor + masked: yes \ No newline at end of file