Skip to content

Commit

Permalink
Upgrade ansible role
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Sep 11, 2024
1 parent f461286 commit 0183eaa
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ansible-imalive/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
imalive_api_version: 1.7
imalive_api_version: 4.0.1
imalive_port: 8099
imalive_wait_time: 300
imalive_force_recreate: true
imalive_monitors: []
1 change: 0 additions & 1 deletion ansible-imalive/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ galaxy_info:
min_ansible_version: 2.2

platforms:
- name: CentOS
- name: RaspberrypiOS
9 changes: 6 additions & 3 deletions ansible-imalive/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
template:
src: "{{ item.template }}.j2"
dest: "{{ item.path }}/{{ item.template }}"
mode: '0644'
mode: "{{ item.mode }}"
with_items:
- { template: docker-compose-imalive.yml , path: "{{ node_home }}" }
- { template: docker-compose-imalive.yml , path: "{{ node_home }}", mode: '0644' }
- { template: .env.imalive , path: "{{ node_home }}", mode: '0644' }
- { template: imalive.yml , path: "{{ node_home }}", mode: '0644' }
- { template: imalive_start.sh , path: "{{ node_home }}", mode: '0755' }

- name: Run the container
become: yes
command: "docker-compose -f {{ node_home }}/docker-compose-imalive.yml up -d --force-recreate"
command: "bash {{ node_home }}/imalive_start.sh"
6 changes: 6 additions & 0 deletions ansible-imalive/templates/.env.imalive.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
WAIT_TIME={{ imalive_wait_time }}
IMALIVE_NODE_NAME={{ node_name }}

{% if imalive_otel_collector_endpoint is defined and imalive_otel_collector_endpoint %}
OTEL_COLLECTOR_ENDPOINT={{ imalive_otel_collector_endpoint }}
{% endif %}
7 changes: 4 additions & 3 deletions ansible-imalive/templates/docker-compose-imalive.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ services:
image: comworkio/imalive-api:{{ imalive_api_version }}-x86
container_name: imalive-api
restart: always
environment:
- WAIT_TIME={{ imalive_wait_time }}
- IMALIVE_NODE_NAME={{ node_name }}
env_file:
- .env.imalive
volumes:
- {{ node_home }}/imalive.yml:/app/imalive.yml:ro
ports:
- {{ imalive_port }}:8080
2 changes: 2 additions & 0 deletions ansible-imalive/templates/imalive.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
monitors: {{ imalive_monitors }}
15 changes: 15 additions & 0 deletions ansible-imalive/templates/imalive_start.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

FORCE_RECREATE_OPT=""
FORCE_RECREATE_FLAG="{{ imalive_force_recreate }}"

if [[ $FORCE_RECREATE_FLAG = "True" ]]; then
FORCE_RECREATE_OPT="--force-recreate"
docker ps -a|awk '($2 ~ "comworkio/imalive"){system("docker rm -f "$1)}' || :
fi

{% if centos_version is defined and (centos_version == "9" or centos_version == 9) %}
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -f {{ node_home }}/docker-compose-imalive.yml up -d $FORCE_RECREATE_OPT
{% else %}
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f {{ node_home }}/docker-compose-imalive.yml up -d $FORCE_RECREATE_OPT
{% endif %}

0 comments on commit 0183eaa

Please sign in to comment.