From 37040f843c1b811f108d3f3231c98e474e997405 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Fri, 3 Jun 2022 05:39:23 +0200 Subject: [PATCH] Feat: ajoute nut au nas --- home.yml | 18 +++++++++--------- roles/nut/defaults/main.yml | 2 ++ roles/nut/handlers/main.yml | 6 ++++++ roles/nut/tasks/debian.yml | 6 ++++++ roles/nut/tasks/main.yml | 21 +++++++++++++++++++++ roles/nut/templates/ups.conf.j2 | 7 +++++++ roles/nut/vars/main.yml | 2 ++ vars/nas.yml | 4 ++++ 8 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 roles/nut/defaults/main.yml create mode 100644 roles/nut/handlers/main.yml create mode 100644 roles/nut/tasks/debian.yml create mode 100644 roles/nut/tasks/main.yml create mode 100644 roles/nut/templates/ups.conf.j2 create mode 100644 roles/nut/vars/main.yml diff --git a/home.yml b/home.yml index 9d9de89..8f467c6 100644 --- a/home.yml +++ b/home.yml @@ -33,14 +33,17 @@ # - name: Secure ssh # include_role: # name: ssh - - - name: Set up nfs network shares server + - name: Set up nuts include_role: - name: nfs_server + name: nut - - name: Set up samba network shares - include_role: - name: samba_server + # - name: Set up nfs network shares server + # include_role: + # name: nfs_server + + # - name: Set up samba network shares + # include_role: + # name: samba_server - name: Install docker debug: @@ -54,9 +57,6 @@ debug: msg: Todo - - name: Set up nuts - debug: - msg: Todo #- name: Set up collectd # include_role: diff --git a/roles/nut/defaults/main.yml b/roles/nut/defaults/main.yml new file mode 100644 index 0000000..29b602a --- /dev/null +++ b/roles/nut/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for nut diff --git a/roles/nut/handlers/main.yml b/roles/nut/handlers/main.yml new file mode 100644 index 0000000..28156f0 --- /dev/null +++ b/roles/nut/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# handlers file for nut +- name: restart nut-server + service: + name: nut-server + state: restarted diff --git a/roles/nut/tasks/debian.yml b/roles/nut/tasks/debian.yml new file mode 100644 index 0000000..fe2e55a --- /dev/null +++ b/roles/nut/tasks/debian.yml @@ -0,0 +1,6 @@ +--- +- name: Debian - Install nut + apt: + name: + - nut + state: present diff --git a/roles/nut/tasks/main.yml b/roles/nut/tasks/main.yml new file mode 100644 index 0000000..62f1e8a --- /dev/null +++ b/roles/nut/tasks/main.yml @@ -0,0 +1,21 @@ +--- +# tasks file for nut +- name: Install os-specific packages + include_tasks: "{{ ansible_os_family | lower }}.yml" + +- name: Enable standalone mode for Nut + lineinfile: + path: /etc/nut/nut.conf + regexp: '^MODE=' + line: MODE=standalone + notify: restart nut-server + +- name: Copy ups.conf + template: + src: ups.conf.j2 + dest: /etc/nut/ups.conf + owner: root + group: root + mode: 0644 + notify: restart nut-server + diff --git a/roles/nut/templates/ups.conf.j2 b/roles/nut/templates/ups.conf.j2 new file mode 100644 index 0000000..833078d --- /dev/null +++ b/roles/nut/templates/ups.conf.j2 @@ -0,0 +1,7 @@ +maxretry = 3 + +{% for ups in upss %} +[{{ ups.name }}] + driver = {{ ups.driver }} + port = {{ ups.port }} +{% endfor %} diff --git a/roles/nut/vars/main.yml b/roles/nut/vars/main.yml new file mode 100644 index 0000000..ace1b81 --- /dev/null +++ b/roles/nut/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for nut diff --git a/vars/nas.yml b/vars/nas.yml index ed97d53..25319df 100644 --- a/vars/nas.yml +++ b/vars/nas.yml @@ -1 +1,5 @@ --- +upss: + - name: eaton650 + driver: usbhid-ups + port: auto