Skip to content

Commit

Permalink
manager: support scripts (#1418)
Browse files Browse the repository at this point in the history
These scripts combine a few things. They are based on the
scripts in the osism/testbed repository.

Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt authored May 3, 2024
1 parent 1e23cdb commit 05f3172
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions roles/manager/tasks/config-scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Include scripts vars file
ansible.builtin.include_vars:
file: scripts.yml

- name: Copy scripts
become: true
ansible.builtin.template:
src: "scripts/{{ item }}.j2"
dest: "/usr/local/bin/{{ item }}"
mode: 0755
owner: "{{ operator_user }}"
group: "{{ operator_group }}"
loop: "{{ manager_scripts }}"
4 changes: 4 additions & 0 deletions roles/manager/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@
- name: Include wrapper config tasks
ansible.builtin.include_tasks: config-wrapper.yml
tags: wrapper

- name: Include scripts config tasks
ansible.builtin.include_tasks: config-scripts.yml
tags: scripts
15 changes: 15 additions & 0 deletions roles/manager/templates/scripts/osism-include.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% raw %}
wait_for_container_healthy() {
local max_attempts="$1"
local name="$2"
local attempt_num=1

until [[ "$(/usr/bin/docker inspect -f '{{.State.Health.Status}}' $name)" == "healthy" ]]; do
if (( attempt_num++ == max_attempts )); then
return 1
else
sleep 5
fi
done
}
{% endraw %}
3 changes: 3 additions & 0 deletions roles/manager/vars/scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
manager_scripts:
- osism-include

0 comments on commit 05f3172

Please sign in to comment.