Skip to content

Commit

Permalink
Updated self-check tasks on a few roles
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodier committed Feb 19, 2024
1 parent 3ff96b9 commit b845cdb
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 45 deletions.
1 change: 1 addition & 0 deletions roles/dovecot/tasks/check/auth.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

- name: Test authentication on the first user
when: system.devel
ansible.builtin.shell: >-
set -o pipefail ;
doveadm auth login -- '{{ user0_uid }}' '{{ user0_password }}'
Expand Down
1 change: 0 additions & 1 deletion roles/dovecot/tasks/check/fts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# These tests are sending and receiving emails
# They need to be done on development servers only
- name: Test parsing script ({{ attachment.description }})
when: system.devel
ansible.builtin.include_tasks: ./fts-test-script.yml
loop: '{{ attachments | selectattr("script_test", "equalto", true) | list }}'
loop_control:
Expand Down
2 changes: 1 addition & 1 deletion roles/dovecot/tasks/check/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
ansible.builtin.include_tasks: check/apparmor.yml

- name: Run full text search checks
when: mail.fts.active
when: mail.fts.active and system.devel
ansible.builtin.include_tasks: check/fts.yml
1 change: 0 additions & 1 deletion roles/ldap-openldap/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ ldap_packages:
install:
- cracklib-runtime
- ldap-utils
- ldapscripts
- ldapvi
- libldap-common
- libpam-pwquality
Expand Down
2 changes: 1 addition & 1 deletion roles/mta-sts/tasks/install/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
loop:
- name: index.html
- name: mta-sts.txt
grafana.grafana.folder: .well-known/
folder: .well-known/
loop_control:
loop_var: file
tags: nginx
Expand Down
2 changes: 2 additions & 0 deletions roles/nginx/tasks/check/apparmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ansible.builtin.shell: >-
set -o pipefail;
aa-status --json | jq '.profiles["/usr/sbin/nginx"]'
args:
executable: /bin/bash
changed_when: false
failed_when: >
aa_status.stdout | trim('"') != "enforce"
2 changes: 2 additions & 0 deletions roles/opendkim/tasks/check/apparmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ansible.builtin.shell: >-
set -o pipefail;
aa-status --json | jq '.profiles["/usr/sbin/opendkim"]'
args:
executable: /bin/bash
changed_when: false
failed_when: >
{{ aa_status.stdout | trim('"') != "enforce" }}
2 changes: 2 additions & 0 deletions roles/opendmarc/tasks/check/apparmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ansible.builtin.shell: >-
set -o pipefail;
aa-status --json | jq '.profiles["/usr/sbin/opendmarc"]'
args:
executable: /bin/bash
changed_when: false
failed_when: >
{{ aa_status.stdout | trim('"') != "enforce" }}
11 changes: 7 additions & 4 deletions roles/postfix/tasks/check/apparmor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---

- name: Check that opendkim is running in enforced mode
- name: Check that postfix kbinary is running in enforced mode
register: aa_status
ansible.builtin.shell: >-
set -o pipefail;
aa-status --json | jq '.profiles["{{ sogo_binary }}"]'
aa-status --json | jq '.profiles["{{ postfix_binary }}"]'
changed_when: false
loop: '{{ sogo_binaries }}'
args:
executable: /bin/bash
loop: '{{ postfix_binaries }}'
loop_control:
loop_var: sogo_binary
loop_var: postfix_binary
failed_when: >
aa_status.stdout | trim('"') != "enforce"
tags: apparmor
13 changes: 10 additions & 3 deletions roles/postfix/tasks/check/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@
- name: Check the LDAP mapping
ansible.builtin.include_tasks: check/ldap-mapping.yml

- name: Check AppArmor
ansible.builtin.include_tasks: check/apparmor.yml
tags: apparmor

- name: Check TLS settings
ansible.builtin.include_tasks: check/tls.yml

- name: Check simple email reception
when: system.devel
ansible.builtin.include_tasks: check/simple-email.yml

- name: Check email reception with UTF8 email address
when: system.devel
ansible.builtin.include_tasks: check/utf8-email.yml

- name: Check email reception with extension
when: system.devel
ansible.builtin.include_tasks: check/extension-email.yml

- name: Check TLS settings
ansible.builtin.include_tasks: check/tls.yml
28 changes: 28 additions & 0 deletions roles/postfix/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,31 @@ exim_packages:
- exim4-base
- exim4-config
- exim4-daemon-light


postfix_binaries:
- /usr/lib/postfix/anvil
- /usr/lib/postfix/bounce
- /usr/lib/postfix/cleanup
- /usr/lib/postfix/discard
- /usr/lib/postfix/error
- /usr/lib/postfix/flush
- /usr/lib/postfix/lmtp
- /usr/lib/postfix/local
- /usr/lib/postfix/master
- /usr/lib/postfix/nqmgr
- /usr/lib/postfix/oqmgr
- /usr/lib/postfix/pickup
- /usr/lib/postfix/pipe
- /usr/lib/postfix/proxymap
- /usr/lib/postfix/qmgr
- /usr/lib/postfix/qmqpd
- /usr/lib/postfix/scache
- /usr/lib/postfix/showq
- /usr/lib/postfix/smtp
- /usr/lib/postfix/smtpd
- /usr/lib/postfix/spawn
- /usr/lib/postfix/tlsmgr
- /usr/lib/postfix/trivial-rewrite
- /usr/lib/postfix/verify
- /usr/lib/postfix/virtual
4 changes: 2 additions & 2 deletions roles/prometheus/tasks/check/nginx.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---

- name: Load prometheus home page
- name: Ensure prometheus is not publicly accessible
delegate_to: localhost
become: false
ansible.builtin.uri:
url: https://prometheus.{{ network.domain }}/
return_content: true
status_code: [ 401 ]
2 changes: 2 additions & 0 deletions roles/rspamd/tasks/check/apparmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ansible.builtin.shell: >-
set -o pipefail;
aa-status --json | jq '.profiles["/usr/bin/rspamd"]'
args:
executable: /bin/bash
changed_when: false
failed_when: >-
{{ aa_status.stdout | trim('"') != "enforce" }}
2 changes: 2 additions & 0 deletions roles/sogo/tasks/check/apparmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ansible.builtin.shell: >-
set -o pipefail;
aa-status --json | jq '.profiles["{{ sogo_binary }}"]'
args:
executable: /bin/bash
changed_when: false
loop: '{{ sogo_binaries }}'
loop_control:
Expand Down
21 changes: 14 additions & 7 deletions roles/user-setup/tasks/check/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
---

- name: Check that every user is in the system, with the correct attributes
ansible.builtin.shell: >-
set -o pipefail ;
getent passwd {{ user.uid }}
changed_when: false
args:
executable: /bin/bash
- name: Check that every user is in the system
ansible.builtin.getent:
key: '{{ user.uid }}'
service: ldap
database: passwd
loop: '{{ users }}'
loop_control:
loop_var: user

- name: Check that every user has a specific group
ansible.builtin.getent:
key: '{{ user.uid }}'
service: ldap
database: group
loop: '{{ users }}'
loop_control:
loop_var: user
2 changes: 1 addition & 1 deletion roles/webdav/tasks/check/dns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
- name: Check the DNS entry
ansible.builtin.getent:
database: hosts
key: 'autodiscover.{{ network.domain }}'
key: 'webdav.{{ network.domain }}'
2 changes: 1 addition & 1 deletion roles/webdav/tasks/check/grade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- name: Load TLS ciphers used
register: tls_ciphers_report
ansible.builtin.shell: sslscan --no-colour autodiscover.{{ network.domain }}:443
ansible.builtin.shell: sslscan --no-colour webdav.{{ network.domain }}:443
changed_when: false

- name: Ensure authorised TLS cipher are used
Expand Down
25 changes: 3 additions & 22 deletions roles/webdav/tasks/check/nginx.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
---

- name: Check if the autodiscover site is active
- name: Ensure the server is not in public access
ansible.builtin.uri:
url: 'https://autodiscover.{{ network.domain }}/'
url: 'https://webdav.{{ network.domain }}/'
method: HEAD
body: ''
status_code: 200
status_code: 401
return_content: true

- name: Download the XML autodiscover file
vars:
email: 'postmaster@{{ network.domain }}'
ansible.builtin.uri:
url: 'https://autodiscover.{{ network.domain }}/autodiscover/autodiscover.xml'
method: POST
body: ''
status_code: 200
dest: /tmp/autodiscover.xml

- name: Check the autodiscover answer is valid
ansible.builtin.shell: xmllint /tmp/autodiscover.xml
changed_when: false

- name: Remove the downloaded file
ansible.builtin.file:
path: /tmp/autodiscover.xml
state: absent
2 changes: 1 addition & 1 deletion roles/website-simple/tasks/check/dns.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

- name: Check the DNS entry
- name: Check that the DNS entry exists
ansible.builtin.getent:
database: hosts
key: 'www.{{ network.domain }}'

0 comments on commit b845cdb

Please sign in to comment.