Skip to content

Commit

Permalink
Add Molecule tests for systemd unit
Browse files Browse the repository at this point in the history
  • Loading branch information
ipr-cnrs committed Aug 19, 2021
1 parent 68c5d4e commit 4267dd4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
22 changes: 21 additions & 1 deletion molecule/archlinux/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
that:
- p.stat.exists

- name: check for nftables.conf
- name: check for filter-input.nft
stat:
path: /etc/nftables.d/filter-input.nft
register: p
Expand All @@ -53,6 +53,26 @@
- '"type filter hook input" in nft.stdout'
- '"type filter hook output" in nft.stdout'

- name: check for fail2ban systemd custom dir
stat:
path: /etc/systemd/system/fail2ban.service.d
register: f2b_systemd_dir

- name: check fail2ban systemd custom dir
assert:
that:
- f2b_systemd_dir.stat.exists and f2b_systemd_dir.stat.isdir

- name: check for fail2ban systemd override
stat:
path: /etc/systemd/system/fail2ban.service.d/override.conf
register: f2b_systemd_override

- name: check fail2ban systemd override
assert:
that:
- f2b_systemd_override.stat.exists

- name: service status - active
command: systemctl is-active nftables.service
register: status
Expand Down
22 changes: 21 additions & 1 deletion molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
that:
- p.stat.exists

- name: check for nftables.conf
- name: check for filter-input.nft
stat:
path: /etc/nftables.d/filter-input.nft
register: p
Expand All @@ -53,6 +53,26 @@
- '"type filter hook input" in nft.stdout'
- '"type filter hook output" in nft.stdout'

- name: check for fail2ban systemd custom dir
stat:
path: /etc/systemd/system/fail2ban.service.d
register: f2b_systemd_dir

- name: check fail2ban systemd custom dir
assert:
that:
- f2b_systemd_dir.stat.exists and f2b_systemd_dir.stat.isdir

- name: check for fail2ban systemd override
stat:
path: /etc/systemd/system/fail2ban.service.d/override.conf
register: f2b_systemd_override

- name: check fail2ban systemd override
assert:
that:
- f2b_systemd_override.stat.exists

- name: service status - active
command: systemctl is-active nftables.service
register: status
Expand Down

0 comments on commit 4267dd4

Please sign in to comment.