Don't combine start/restart and rename cfg to conf

This commit is contained in:
Wojciech Kozlowski 2022-08-30 15:51:02 +02:00
parent 2045cbd4d8
commit 86170d0393

View File

@ -18,7 +18,7 @@
src: ./root/etc/ssh/sshd_config.d/00-yggdrasil.conf.j2 src: ./root/etc/ssh/sshd_config.d/00-yggdrasil.conf.j2
dest: /etc/ssh/sshd_config.d/00-yggdrasil.conf dest: /etc/ssh/sshd_config.d/00-yggdrasil.conf
mode: 0600 mode: 0600
register: sshd_cfg register: sshd_conf
- name: Restart sshd - name: Restart sshd
service: service:
@ -26,7 +26,7 @@
enabled: yes enabled: yes
state: restarted state: restarted
when: when:
sshd_cfg is changed sshd_conf is changed
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Firewall configuration. # Firewall configuration.
@ -35,23 +35,26 @@
- name: Install nftables - name: Install nftables
apt: apt:
name: nftables name: nftables
register: nftables_install
- name: Configure nftables - name: Configure nftables
template: template:
src: ./root/etc/nftables.conf.j2 src: ./root/etc/nftables.conf.j2
dest: /etc/nftables.conf dest: /etc/nftables.conf
mode: 0755 mode: 0755
register: nftables_cfg register: nftables_conf
- name: Enable/start/restart nftables - name: Enable/start nftables
service:
name: nftables
state: started
enabled: yes
- name: Restart nftables
service: service:
name: nftables name: nftables
state: restarted state: restarted
enabled: yes
when: when:
nftables_install is changed or nftables_conf is changed
nftables_cfg is changed
# ---------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------
# NTP configuration. # NTP configuration.
@ -101,14 +104,13 @@
- postfix - postfix
- ca-certificates - ca-certificates
- libsasl2-modules - libsasl2-modules
register: mail_postfix_install
- name: Configure postfix - name: Configure postfix
template: template:
src: ./root/etc/postfix/main.cf.j2 src: ./root/etc/postfix/main.cf.j2
dest: /etc/postfix/main.cf dest: /etc/postfix/main.cf
mode: 0644 mode: 0644
register: mail_postfix_cfg register: mail_postfix_conf
- name: Configure credentials - name: Configure credentials
template: template:
@ -127,16 +129,20 @@
path: /etc/postfix/sasl_passwd.db path: /etc/postfix/sasl_passwd.db
mode: 0600 mode: 0600
- name: Enable/start/restart postfix - name: Enable/start postfix
service: service:
name: postfix name: postfix
enabled: yes enabled: yes
state: started
- name: Restart postfix
service:
name: postfix
state: restarted state: restarted
when: when:
mail_mailname is changed or mail_mailname is changed or
mail_aliases is changed or mail_aliases is changed or
mail_postfix_install is changed or mail_postfix_conf is changed or
mail_postfix_cfg is changed or
mail_postfix_credentials is changed mail_postfix_credentials is changed
# ---------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------
@ -255,20 +261,23 @@
- name: Install acpupsd - name: Install acpupsd
apt: apt:
name: apcupsd name: apcupsd
register: apcupsd_install
- name: Apcupsd configuration - name: Apcupsd configuration
copy: copy:
src: ./root/etc/apcupsd/apcupsd.conf src: ./root/etc/apcupsd/apcupsd.conf
dest: /etc/apcupsd/apcupsd.conf dest: /etc/apcupsd/apcupsd.conf
mode: 0644 mode: 0644
register: apcupsd_cfg register: apcupsd_conf
- name: Enable/start/restart apcupsd - name: Enable/start apcupsd
service: service:
name: apcupsd name: apcupsd
enabled: yes enabled: yes
state: started
- name: Restart apcupsd
service:
name: apcupsd
state: restarted state: restarted
when: when:
apcupsd_install is changed or apcupsd_conf is changed
apcupsd_cfg is changed