diff --git a/playbooks/00-hosts.yml b/playbooks/00-hosts.yml deleted file mode 100644 index 9c48465..0000000 --- a/playbooks/00-hosts.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Configure yggdrasil extras - hosts: yggdrasil - - tasks: - - import_tasks: tasks/hosts/smart.yml diff --git a/playbooks/tasks/hosts/smart.yml b/playbooks/tasks/hosts/smart.yml deleted file mode 100644 index 5b9ab1c..0000000 --- a/playbooks/tasks/hosts/smart.yml +++ /dev/null @@ -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 diff --git a/playbooks/filesystem/yggdrasil/etc/smartd.conf b/plays/roles/system_smart/files/smartd.conf similarity index 100% rename from playbooks/filesystem/yggdrasil/etc/smartd.conf rename to plays/roles/system_smart/files/smartd.conf diff --git a/plays/roles/system_smart/tasks/main.yml b/plays/roles/system_smart/tasks/main.yml new file mode 100644 index 0000000..6a7737c --- /dev/null +++ b/plays/roles/system_smart/tasks/main.yml @@ -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 diff --git a/plays/roles/system_ups/tasks/main.yml b/plays/roles/system_ups/tasks/main.yml index 8168fb8..e6f6e4d 100644 --- a/plays/roles/system_ups/tasks/main.yml +++ b/plays/roles/system_ups/tasks/main.yml @@ -25,5 +25,5 @@ name: "apcupsd" state: "restarted" when: - apcupsd_conf is changed and - apcupsd_start is not changed + apcupsd_conf.changed and + not apcupsd_start.changed diff --git a/plays/system.yml b/plays/system.yml index 12c8939..95c056d 100644 --- a/plays/system.yml +++ b/plays/system.yml @@ -4,6 +4,8 @@ roles: - role: "system_ups" tags: "role:system_ups" + - role: "system_smart" + tags: "role:system_smart" - role: "system_zfs" tags: "role:system_zfs"