Create system_smart role

This commit is contained in:
Wojciech Kozlowski 2022-12-04 17:34:50 +01:00
parent 2fffbbfd19
commit c3328ddbf4
6 changed files with 33 additions and 37 deletions

View File

@ -1,6 +0,0 @@
---
- name: Configure yggdrasil extras
hosts: yggdrasil
tasks:
- import_tasks: tasks/hosts/smart.yml

View File

@ -1,29 +0,0 @@
- name: Install smartmontools
apt:
name: smartmontools
- name: Smartd configuration
copy:
src: ./filesystem/{{ ansible_hostname }}/etc/smartd.conf
dest: /etc/smartd.conf
mode: 0644
register: smartd_conf
- name: Enable smartmontools
systemd:
name: smartmontools
enabled: yes
- name: Start smartmontools
systemd:
name: smartmontools
state: started
register: smartd_start
- name: Restart smartmontools
systemd:
name: smartmontools
state: restarted
when:
smartd_conf is changed and
smartd_start is not changed

View File

@ -0,0 +1,29 @@
- name: "install smartmontools"
ansible.builtin.apt:
name: "smartmontools"
- name: "smartd configuration"
ansible.builtin.copy:
src: "./smartd.conf"
dest: "/etc/smartd.conf"
mode: 0644
register: smartd_conf
- name: "enable smartmontools"
ansible.builtin.systemd:
name: "smartmontools"
enabled: true
- name: "start smartmontools"
ansible.builtin.systemd:
name: "smartmontools"
state: "started"
register: smartd_start
- name: "restart smartmontools"
ansible.builtin.systemd:
name: "smartmontools"
state: "restarted"
when:
smartd_conf.changed and
not smartd_start.changed

View File

@ -25,5 +25,5 @@
name: "apcupsd" name: "apcupsd"
state: "restarted" state: "restarted"
when: when:
apcupsd_conf is changed and apcupsd_conf.changed and
apcupsd_start is not changed not apcupsd_start.changed

View File

@ -4,6 +4,8 @@
roles: roles:
- role: "system_ups" - role: "system_ups"
tags: "role:system_ups" tags: "role:system_ups"
- role: "system_smart"
tags: "role:system_smart"
- role: "system_zfs" - role: "system_zfs"
tags: "role:system_zfs" tags: "role:system_zfs"