From 39035880951b3f5eba9ae9b221e79d042cbdfd87 Mon Sep 17 00:00:00 2001 From: Tobias Lehmann Date: Fri, 18 Oct 2024 19:26:40 +0200 Subject: [PATCH] added harvester --- inventory/hosts.yml | 2 + playbooks/captica-automation-harvester.yml | 64 ++++++++++++++++++++++ templates/harvester/.env.j2 | 4 ++ templates/harvester/docker-compose.yml.j2 | 44 +++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 playbooks/captica-automation-harvester.yml create mode 100644 templates/harvester/.env.j2 create mode 100644 templates/harvester/docker-compose.yml.j2 diff --git a/inventory/hosts.yml b/inventory/hosts.yml index 432bf93..49f615f 100644 --- a/inventory/hosts.yml +++ b/inventory/hosts.yml @@ -16,6 +16,8 @@ all: ansible_host: 192.168.180.190 timescaledb: ansible_host: 192.168.150.130 + harvester: + ansible_host: 192.168.150.175 bankmanager: ansible_host: 192.168.110.20 urbackup: diff --git a/playbooks/captica-automation-harvester.yml b/playbooks/captica-automation-harvester.yml new file mode 100644 index 0000000..f9d0bcc --- /dev/null +++ b/playbooks/captica-automation-harvester.yml @@ -0,0 +1,64 @@ +# +# +# Automated installation for bankmanager +# +# Project: playbooks +# Author: Tobias Lehmann +# License: MIT License (see LICENSE.md) +# +# Copyright (c) captica GmbH est. 2021 +# +- hosts: "leh01" + name: Create container + vars: + lxc_id: 1035 + lxc_name: harvester + lxc_domain: leh01.local + lxc_template: "local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst" + lxc_mac: CC:CC:CC:15:01:75 + lxc_bridge: vmbr150 + lxc_vlan: "" + lxc_disk: datapool:32 + lxc_cpu: 2 + lxc_memory: 2048 + lxc_swap: 1024 + lxc_mounts: '{"mp0":"lxc-harvester:50,mp=/opt/harvester"}' + lxc_ssh_pub_key: ~/.ssh/id_ed25519_ansible.pub + roles: + - lxc-container + +- hosts: "harvester" + vars: + hostname: harvester + tools_install_users: + - root + - ansible + ssh_pubkeys_root: + - "../files/ssh/root.pub" + ssh_pubkeys_ansible: + - "../files/ssh/id_ed25519_ansible.pub" + roles: + - linux-base-install + - zsh + - vim + - fzf + - linux-docker + +- hosts: "harvester" + tags: + - harvester + - install + vars: + service_name: harvester + service_directory: /opt/harvester + service_volume_dirs: + - appdata + - db + service_user_name: harvester + service_user_id: 1020 + service_group_name: harvester + service_group_id: 1020 + harvester_version: latest + tasks: + - name: "Install harvester application" + include_tasks: setup-docker-application.yml \ No newline at end of file diff --git a/templates/harvester/.env.j2 b/templates/harvester/.env.j2 new file mode 100644 index 0000000..71979c4 --- /dev/null +++ b/templates/harvester/.env.j2 @@ -0,0 +1,4 @@ +SMTP_PASSWORD={{smtp_relay_password}} +DB_NAME=harvester +DB_USER=captica +DB_PASSWORD=captica \ No newline at end of file diff --git a/templates/harvester/docker-compose.yml.j2 b/templates/harvester/docker-compose.yml.j2 new file mode 100644 index 0000000..c97664b --- /dev/null +++ b/templates/harvester/docker-compose.yml.j2 @@ -0,0 +1,44 @@ +services: + db: + image: timescale/timescaledb:pg16 + restart: always + environment: + - POSTGRES_USER=${DB_USER} + - POSTGRES_PASSWORD=${DB_PASSWORD} + - POSTGRES_DB=bankmanager + networks: + - default + volumes: + - {{ service_directory }}/data/db:/var/lib/postgresql/data + ports: + - '5432:5432' + + app: + image: git.captica.de/captica/de.captica.expert.connect-device-harvester:latest + environment: + SPRING_APPLICATION_JSON: '{ + "USER_UID": "{{ service_user_id }}", + "USER_GID": "{{ service_group_id }}", + "spring.datasource.url" : "jdbc:postgresql://db:5432/harvester", + "spring.datasource.username" : "${DB_USER}", + "spring.datasource.password" : "${DB_PASSWORD}", + "connectdeviceharvester.knxGateway.ip" : "192.168.150.69", + "connectdeviceharvester.knxGateway.port" : "3671", + "connectdeviceharvester.knxGateway.useNat" : "true", + "connectdeviceharvester.localPort" : "3671" + }' + restart: always + volumes: + - {{ service_directory }}/data/appdata:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + networks: + - default + +networks: + default: + ipam: + driver: default + config: + - subnet: 172.2.0.0/16 + gateway: 172.2.0.1 \ No newline at end of file