sendmail: ansible-lint fixes

This commit is contained in:
Timo Makinen 2022-10-30 15:28:30 +00:00
parent 09921538da
commit 64e868fc10
2 changed files with 43 additions and 38 deletions

View file

@ -1,13 +1,19 @@
--- ---
- name: Restart sendmail
- name: restart sendmail ansible.builtin.service:
service:
name: sendmail name: sendmail
state: restarted state: restarted
- name: update sendmail config - name: Update sendmail config
command: make -C /etc/mail all ansible.builtin.command:
notify: restart sendmail argv:
- make
- -C
- /etc/mail
- all
notify: Restart sendmail
- name: update aliases - name: Update aliases
command: newaliases ansible.builtin.command:
argv:
- newaliases

View file

@ -1,7 +1,6 @@
--- ---
- name: Install packages
- name: install packages ansible.builtin.package:
package:
name: "{{ item }}" name: "{{ item }}"
state: installed state: installed
with_items: with_items:
@ -9,16 +8,16 @@
- sendmail - sendmail
- sendmail-cf - sendmail-cf
- name: create root cert directory - name: Create root cert directory
file: ansible.builtin.file:
path: /etc/mail/certs path: /etc/mail/certs
state: directory state: directory
mode: 0755 mode: 0755
owner: root owner: root
group: "{{ ansible_wheel }}" group: "{{ ansible_wheel }}"
- name: copy private key - name: Copy private key
copy: ansible.builtin.copy:
dest: "{{ tls_private }}/{{ mail_server }}.key" dest: "{{ tls_private }}/{{ mail_server }}.key"
src: "{{ item }}" src: "{{ item }}"
mode: 0600 mode: 0600
@ -29,10 +28,10 @@
- "/srv/ca/private/{{ mail_server }}.key" - "/srv/ca/private/{{ mail_server }}.key"
- "/srv/ca/private/{{ inventory_hostname }}.key" - "/srv/ca/private/{{ inventory_hostname }}.key"
tags: certificates tags: certificates
notify: restart sendmail notify: Restart sendmail
- name: copy certificate - name: Copy certificate
copy: ansible.builtin.copy:
src: "{{ item }}" src: "{{ item }}"
dest: "{{ tls_certs }}/{{ mail_server }}.crt" dest: "{{ tls_certs }}/{{ mail_server }}.crt"
mode: 0644 mode: 0644
@ -44,10 +43,10 @@
- "/srv/ca/certs/hosts/{{ mail_server }}.crt" - "/srv/ca/certs/hosts/{{ mail_server }}.crt"
- "/srv/ca/certs/hosts/{{ inventory_hostname }}.crt" - "/srv/ca/certs/hosts/{{ inventory_hostname }}.crt"
tags: certificates tags: certificates
notify: restart sendmail notify: Restart sendmail
- name: copy certificate chain - name: Copy certificate chain
copy: ansible.builtin.copy:
src: "{{ item }}" src: "{{ item }}"
dest: "{{ tls_certs }}/{{ mail_server }}-chain.crt" dest: "{{ tls_certs }}/{{ mail_server }}-chain.crt"
mode: 0644 mode: 0644
@ -58,15 +57,15 @@
- "/srv/letsencrypt/live/{{ mail_server }}/chain.pem" - "/srv/letsencrypt/live/{{ mail_server }}/chain.pem"
- "/srv/ca/certs/ca.crt" - "/srv/ca/certs/ca.crt"
tags: certificates tags: certificates
notify: restart sendmail notify: Restart sendmail
- name: fix selinux contexts from data directory - name: Fix SELinux contexts from data directory
sefcontext: community.general.sefcontext:
path: "/export/mail(/.*)?" path: "/export/mail(/.*)?"
setype: mail_spool_t setype: mail_spool_t
- name: create data directory - name: Create data directory
file: ansible.builtin.file:
path: /export/mail path: /export/mail
state: directory state: directory
mode: 0775 mode: 0775
@ -74,16 +73,16 @@
group: mail group: mail
setype: _default setype: _default
- name: backup old data directory - name: Backup old data directory
command: ansible.builtin.command:
argv: argv:
- mv - mv
- /var/spool/mail - /var/spool/mail
- /var/spool/mail.backup - /var/spool/mail.backup
creates: /var/spool/mail.backup creates: /var/spool/mail.backup
- name: link data directory - name: Link data directory
file: ansible.builtin.file:
path: /var/spool/mail path: /var/spool/mail
src: /export/mail src: /export/mail
state: link state: link
@ -93,27 +92,27 @@
follow: false follow: false
force: true force: true
- name: copy sendmail config template - name: Create sendmail.mc
template: ansible.builtin.template:
src: sendmail.mc.j2 src: sendmail.mc.j2
dest: /etc/mail/sendmail.mc dest: /etc/mail/sendmail.mc
mode: 0644 mode: 0644
owner: root owner: root
group: "{{ ansible_wheel }}" group: "{{ ansible_wheel }}"
validate: /bin/sh -c '/usr/bin/m4 %s > /dev/null' validate: /bin/sh -c '/usr/bin/m4 %s > /dev/null'
notify: update sendmail config notify: Update sendmail config
- name: copy aliases - name: Copy aliases
copy: ansible.builtin.copy:
src: aliases src: aliases
dest: /etc/aliases dest: /etc/aliases
mode: 0644 mode: 0644
owner: root owner: root
group: "{{ ansible_wheel }}" group: "{{ ansible_wheel }}"
notify: update aliases notify: Update aliases
- name: enable sendmail service - name: Enable service
service: ansible.builtin.service:
name: sendmail name: sendmail
enabled: true enabled: true
state: started state: started