fix(debian): refs #8318 check por apparmor and postfix services #41

Merged
juan merged 1 commits from 8318-checkAppArmorPostfix into main 2024-12-18 08:37:47 +00:00
2 changed files with 49 additions and 41 deletions
Showing only changes of commit e67b766374 - Show all commits

View File

@ -1,29 +1,33 @@
- name: Install exim packages - name: Getting service facts to check for postfix
apt: service_facts:
name: exim4 - when: "'postfix.service' not in ansible_facts.services"
state: present block:
- name: Prepare exim configuration - name: Install exim packages
blockinfile: apt:
path: /etc/exim4/update-exim4.conf.conf name: exim4
marker_begin: '--- BEGIN VN ---' state: present
marker_end: '--- END VN ---' - name: Prepare exim configuration
marker: "# {mark}" blockinfile:
block: | path: /etc/exim4/update-exim4.conf.conf
dc_eximconfig_configtype='satellite' marker_begin: '--- BEGIN VN ---'
dc_other_hostnames='{{ ansible_fqdn }}' marker_end: '--- END VN ---'
dc_local_interfaces='127.0.0.1' marker: "# {mark}"
dc_readhost='{{ ansible_fqdn }}' block: |
dc_smarthost='{{ smtp_server }}' dc_eximconfig_configtype='satellite'
dc_hide_mailname='true' dc_other_hostnames='{{ ansible_fqdn }}'
state: present dc_local_interfaces='127.0.0.1'
create: yes dc_readhost='{{ ansible_fqdn }}'
mode: u=rw,g=r,o=r dc_smarthost='{{ smtp_server }}'
notify: update exim configuration dc_hide_mailname='true'
register: exim_config state: present
- name: Force execution of handlers immediately create: yes
meta: flush_handlers mode: u=rw,g=r,o=r
- name: Sending mail to verify relay host configuration works notify: update exim configuration
shell: > register: exim_config
sleep 2; echo "If you see this message, relayhost on {{ ansible_fqdn }} has been configured correctly." \ - name: Force execution of handlers immediately
| mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ sysadmin_mail }}" meta: flush_handlers
when: exim_config.changed - 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

View File

@ -1,12 +1,16 @@
- name: Stop AppArmor - name: Getting service facts to check for apparmor
systemd: service_facts:
name: apparmor - when: "'apparmor.service' in ansible_facts.services"
state: stopped block:
- name: Disable AppArmor service - name: Stop AppArmor
systemd: systemd:
name: apparmor name: apparmor
enabled: no state: stopped
- name: Mask AppArmor service - name: Disable AppArmor service
systemd: systemd:
name: apparmor name: apparmor
masked: yes enabled: no
- name: Mask AppArmor service
systemd:
name: apparmor
masked: yes