From 6fcdffd6c48309feb086742dcfbfae63391782b5 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Tue, 17 Mar 2026 16:17:06 +0000 Subject: [PATCH] Updated feedstack to include weatherdb and weatherapi containers --- defaults/main.yml | 12 ++++++++++++ tasks/main.yml | 7 +++++++ templates/weatherapi/config.yml.j2 | 9 +++++++++ templates/weatherfeeder/config.yml.j2 | 10 ++++++++++ vars/containers/weatherapi.yml | 22 ++++++++++++++++++++++ vars/containers/weatherdb.yml | 19 +++++++++++++++++++ vars/containers/weatherfeeder.yml | 1 + 7 files changed, 80 insertions(+) create mode 100644 templates/weatherapi/config.yml.j2 create mode 100644 vars/containers/weatherapi.yml create mode 100644 vars/containers/weatherdb.yml diff --git a/defaults/main.yml b/defaults/main.yml index fe494c1..cbb8e20 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,7 +17,19 @@ feedstack_weatherfeeder_container_tag: "latest" feedstack_weatherprocessor_container_image: "harbor.maximumdirect.net/library/weatherprocessor" feedstack_weatherprocessor_container_tag: "latest" +# Define the default weatherapi container image and tag. +feedstack_weatherapi_container_image: "harbor.maximumdirect.net/library/weatherapi" +feedstack_weatherapi_container_tag: "latest" + # Define the default NATS container image and tag. feedstack_nats_container_image: "nats" feedstack_nats_container_tag: "linux" +# Define the default weatherdb container image and tag. +feedstack_weatherdb_container_image: "postgres" +feedstack_weatherdb_container_tag: "16" + +# Define the default weatherdb database user and password. +feedstack_weatherdb_user: "weatherdb" +feedstack_weatherdb_password: "weatherdb" +feedstack_weatherdb_database: "weatherdb" \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 3e7a89d..0fb1215 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,6 +6,7 @@ loop: - weatherfeeder - weatherprocessor + - weatherapi - nats/config - nats/data loop_control: @@ -19,6 +20,12 @@ dest: "{{ docker_appdata_directory }}/weatherfeeder/config.yml" become: true + - name: Create the weatherapi configuration file from the provided template. + template: + src: "weatherapi/config.yml.j2" + dest: "{{ docker_appdata_directory }}/weatherapi/config.yml" + become: true + - name: Create the weatherprocessor configuration file from the provided template. template: src: "weatherprocessor/config.yml.j2" diff --git a/templates/weatherapi/config.yml.j2 b/templates/weatherapi/config.yml.j2 new file mode 100644 index 0000000..3812100 --- /dev/null +++ b/templates/weatherapi/config.yml.j2 @@ -0,0 +1,9 @@ +--- + - name: weatherdb + driver: postgres + params: + uri: postgres://weatherdb:5432/{{ feedstack_weatherdb_database }}?sslmode=disable + username: {{ feedstack_weatherdb_user }} + password: {{ feedstack_weatherdb_password }} + +... \ No newline at end of file diff --git a/templates/weatherfeeder/config.yml.j2 b/templates/weatherfeeder/config.yml.j2 index 59649d6..e64bc7e 100644 --- a/templates/weatherfeeder/config.yml.j2 +++ b/templates/weatherfeeder/config.yml.j2 @@ -73,12 +73,22 @@ sinks: params: url: nats://nats:4222 exchange: weatherfeeder + + - name: weatherdb + driver: postgres + params: + uri: postgres://weatherdb:5432/{{ feedstack_weatherdb_database }}?sslmode=disable + username: {{ feedstack_weatherdb_user }} + password: {{ feedstack_weatherdb_password }} # optional: route events to this sink routes: - sink: nats_weatherfeeder kinds: ["observation", "forecast", "alert"] + - sink: weatherdb + kinds: ["observation", "forecast", "alert"] + - sink: stdout kinds: ["observation", "forecast", "alert"] ... \ No newline at end of file diff --git a/vars/containers/weatherapi.yml b/vars/containers/weatherapi.yml new file mode 100644 index 0000000..e980cff --- /dev/null +++ b/vars/containers/weatherapi.yml @@ -0,0 +1,22 @@ +--- +weatherapi: + + # Define the name of this container. + name: "weatherapi" + + # Define the docker image to be used for this container. + image: "{{ feedstack_weatherapi_container_image }}:{{ feedstack_weatherapi_container_tag }}" + + # Define ports that should be opened to the outside world. + ports: + - "8080:8080" + + # Define the volumes that should be mounted into the container. + volumes: + - "{{ docker_appdata_directory }}/weatherapi/config.yml:/weatherapi/config.yml:ro" + + # Define the dependencies for this container. + dependencies: + - weatherdb + +... diff --git a/vars/containers/weatherdb.yml b/vars/containers/weatherdb.yml new file mode 100644 index 0000000..471164d --- /dev/null +++ b/vars/containers/weatherdb.yml @@ -0,0 +1,19 @@ +--- +weatherdb: + + # Define the name of this container. + name: "weatherdb" + + # Define the docker image to be used for this container. + image: "{{ feedstack_weatherdb_container_image }}:{{ feedstack_weatherdb_container_tag }}" + + # Define the volumes that should be mounted into the container. + volumes: + - "{{ docker_appdata_directory }}/weatherdb/db:/var/lib/postgresql/data" + + # Define environment variables to be passed to the container. + environment_variables: + - "POSTGRES_USER={{ feedstack_weatherdb_user }}" + - "POSTGRES_PASSWORD={{ feedstack_weatherdb_password }}" + - "POSTGRES_DB={{ feedstack_weatherdb_database }}" +... diff --git a/vars/containers/weatherfeeder.yml b/vars/containers/weatherfeeder.yml index 1ffcc31..c680e8e 100644 --- a/vars/containers/weatherfeeder.yml +++ b/vars/containers/weatherfeeder.yml @@ -23,6 +23,7 @@ weatherfeeder: # Define the dependencies for this container. dependencies: - nats + - weatherdb # Define environment variables to be passed to the container. #environment_variables: []