diff --git a/hosts/production b/hosts/production index d575b20..7099e87 100644 --- a/hosts/production +++ b/hosts/production @@ -2,6 +2,10 @@ all: children: fet: hosts: - ariane + ariane: + lxc-pet-01: + fet_container: + hosts: + lxc-pet-01 vars: ansible_python_interpreter=/usr/bin/python3 diff --git a/hosts/production_pet b/hosts/production_pet new file mode 100644 index 0000000..fffed14 --- /dev/null +++ b/hosts/production_pet @@ -0,0 +1,2 @@ +[fet_container] +lxc-pet-01 diff --git a/roles/USV_monitoring/files/99_nut-serialups.rules b/roles/USV_monitoring/files/99_nut-serialups.rules new file mode 100644 index 0000000..2b42d4a --- /dev/null +++ b/roles/USV_monitoring/files/99_nut-serialups.rules @@ -0,0 +1,4 @@ +#This file is written by ansible. Manual changes will be reverted. 2.2018, pet + + +KERNEL=="ttyS0", GROUP="nut" diff --git a/roles/USV_monitoring/files/nut.conf b/roles/USV_monitoring/files/nut.conf new file mode 100755 index 0000000..08de6d6 --- /dev/null +++ b/roles/USV_monitoring/files/nut.conf @@ -0,0 +1,4 @@ +#This file is written by ansible. Manual changes will be reverted. 2.2018, pet + +#This is the master server for the UPS, all others should be netclient. +MODE=netserver diff --git a/roles/USV_monitoring/files/ups.conf b/roles/USV_monitoring/files/ups.conf new file mode 100644 index 0000000..afea54b --- /dev/null +++ b/roles/USV_monitoring/files/ups.conf @@ -0,0 +1,6 @@ +#This file is written by ansible. Manual changes will be reverted. 2.2018, pet + +[VSD1500] + driver = riello_ser + port = /dev/ttyS1 + desc = "Riello VSD 1500; RS-Components: 869-5016; bought: 1.2018" diff --git a/roles/USV_monitoring/files/upsd.conf b/roles/USV_monitoring/files/upsd.conf new file mode 100644 index 0000000..3d596b6 --- /dev/null +++ b/roles/USV_monitoring/files/upsd.conf @@ -0,0 +1,4 @@ +#This file is written by ansible. Manual changes will be reverted. 2.2018, pet + +LISTEN 192.168.86.116 3493 +LISTEN 127.0.0.1 3493 diff --git a/roles/USV_monitoring/files/upsd.users b/roles/USV_monitoring/files/upsd.users new file mode 100644 index 0000000..9cc22a2 --- /dev/null +++ b/roles/USV_monitoring/files/upsd.users @@ -0,0 +1,10 @@ +#This file is written by ansible. Manual changes will be reverted. 2.2018, pet + +[monmaster] + password = DorsAz4BK7XiMKDfPj + upsmon master + + +[monuser] + password = sEfguPcZbn99qnnTUj + upsmon slave diff --git a/roles/USV_monitoring/files/upsmon.conf b/roles/USV_monitoring/files/upsmon.conf new file mode 100644 index 0000000..917acbf --- /dev/null +++ b/roles/USV_monitoring/files/upsmon.conf @@ -0,0 +1,3 @@ +#This file is written by ansible. Manual changes will be reverted. 2.2018, pet + +MONITOR VSD1500@lxc-pet-01 1 monmaster DorsAz4BK7XiMKDfPj master diff --git a/roles/USV_monitoring/tasks/main.yml b/roles/USV_monitoring/tasks/main.yml index e69de29..ef193d2 100644 --- a/roles/USV_monitoring/tasks/main.yml +++ b/roles/USV_monitoring/tasks/main.yml @@ -0,0 +1,70 @@ +- name: Check NUT (Network UPS Tools) installation + apt: + update_cache: yes + name: nut + +- name: NUT mode - /etc/nut/nut.conf + copy: + dest: /etc/nut/nut.conf + src: nut.conf + owner: root + group: nut + mode: 0640 + backup: yes + +- name: UPS conf - /etc/nut/ups.conf + copy: + dest: /etc/nut/ups.conf + src: ups.conf + owner: root + group: nut + mode: 0640 + backup: yes + +- name: UPS ip:port - /etc/nut/upsd.conf + copy: + dest: /etc/nut/upsd.conf + src: upsd.conf + owner: root + group: nut + mode: 0640 + backup: yes + +- name: NUT user - /etc/nut/upsd.users + copy: + dest: /etc/nut/upsd.users + src: upsd.users + owner: root + group: nut + mode: 0640 + backup: yes + +- name: NUT monitoring - /etc/nut/upsmon.conf + copy: + dest: /etc/nut/upsmon.conf + src: upsmon.conf + owner: root + group: nut + mode: 0640 + backup: yes + +#- name: Serial port configuration- /etc/udev/rules.d/99_nut-serialups.rules +# copy: +# dest: /etc/udev/rules.d/99_nut-serialups.rules +# src: 99_nut-serialups.rules +# owner: root +# group: nut +# mode: 0640 +# backup: yes +# +#- name: Force udev to reload Serialports +# command: "udevadm control --reload-rules" +# +#- name: Force udev to reload Serialports +# command: "udevadm trigger" + +- name: Stop the upsd + command: "upsd -c stop" + +- name: Start the upsd + command: upsd diff --git a/site.yml b/site.yml index b1d687e..2b8ea94 100644 --- a/site.yml +++ b/site.yml @@ -25,6 +25,8 @@ - hosts: all gather_facts: False tasks: + - name: install python + raw: test -e /usr/bin/python || (apt-get update && apt-get install -y python) - name: install python3 raw: test -e /usr/bin/python3 || (apt-get update && apt-get install -y python3) @@ -33,3 +35,11 @@ - common # - rvm1-ansible - ariane + +- hosts: fet + roles: + - common + +- hosts: lxc-pet-01 + roles: + - USV_monitoring