From e3683744fc64eca7d4c96a2280876cfb501196e1 Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Sun, 22 Dec 2024 18:14:16 +0100 Subject: [PATCH] bank: Update inflatinator dependencies --- roles/bank/tasks/inflatinator.service | 9 +++++++++ roles/bank/tasks/inflatinator.yaml | 23 ++++++++++++++++++++++- roles/monitoring/tasks/mqtt_exporter.yaml | 4 ++-- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 roles/bank/tasks/inflatinator.service diff --git a/roles/bank/tasks/inflatinator.service b/roles/bank/tasks/inflatinator.service new file mode 100644 index 0000000..c4a2397 --- /dev/null +++ b/roles/bank/tasks/inflatinator.service @@ -0,0 +1,9 @@ +[Unit] +Description=Update product prices in Revbank + +[Service] +Type=oneshot +ExecStart=/opt/revbank-inflatinator/.venv/bin/python /opt/revbank-inflatinator/inflatinator/ /home/bank/revbank.products +EnvironmentFile=/etc/revbank-inflatinator/env.conf +User=bank +Group=bank diff --git a/roles/bank/tasks/inflatinator.yaml b/roles/bank/tasks/inflatinator.yaml index dc687a3..02452ad 100644 --- a/roles/bank/tasks/inflatinator.yaml +++ b/roles/bank/tasks/inflatinator.yaml @@ -1,7 +1,7 @@ --- - name: Install dependencies ansible.builtin.apt: - name: [ links, python3-pyquery ] + name: virtualenv state: present - name: Clone revbank-inflatinator source @@ -10,3 +10,24 @@ version: main dest: /opt/revbank-inflatinator accept_hostkey: yes + +- name: Create virtualenv + ansible.builtin.command: + cmd: virtualenv /opt/revbank-inflatinator/.venv + args: + creates: /opt/revbank-inflatinator/.venv + +- name: Install Python dependencies + ansible.builtin.shell: + cmd: . .venv/bin/activate && pip install -r requirements.txt + args: + chdir: /opt/revbank-inflatinator + +- name: Install service + ansible.builtin.template: + src: inflatinator.service + dest: /etc/systemd/system/revbank-inflatinator.service + owner: root + group: root + mode: 0644 + notify: Daemon reload diff --git a/roles/monitoring/tasks/mqtt_exporter.yaml b/roles/monitoring/tasks/mqtt_exporter.yaml index b41fc42..0ae5d07 100644 --- a/roles/monitoring/tasks/mqtt_exporter.yaml +++ b/roles/monitoring/tasks/mqtt_exporter.yaml @@ -24,7 +24,7 @@ group: root mode: 0644 notify: - - daemon reload + - Daemon reload - restart mqtt_exporter - name: Install config file @@ -35,7 +35,7 @@ group: root mode: 0644 notify: - - daemon reload + - Daemon reload - restart mqtt_exporter - ansible.builtin.meta: flush_handlers