fixed ansible playbooks

This commit is contained in:
IcyAltair 2025-12-26 18:05:36 +03:00
parent a174760191
commit 68d4976a97
5 changed files with 24 additions and 45 deletions

View file

@ -6,21 +6,11 @@
ansible.builtin.shell: free -m | awk 'NR==2{printf "%d", ($2-$3)}'
register: sys_mem_info
- name: Delete bm-smi log
ansible.builtin.shell: rm -f bm-smi.log
register: del_file
- name: Save bm-smi log
ansible.builtin.shell: /opt/sophon/libsophon-0.4.8/bin/bm-smi -noloop --file=./bm-smi.log
register: save_file
- name: Check used device memory
ansible.builtin.shell: cat bm-smi.log | grep -o '[0-9]\+MB/ ' | grep -o -E '[0-9]+'
register: dev_mem_info
- name: Check used TPU
ansible.builtin.shell: cat bm-smi.log | grep -o '[0-9]\+%' | grep -o -E -m 1 '[0-9]+'
register: tpu_info
- name: Check used GPU
ansible.builtin.shell: |
nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total --format=csv,noheader,nounits
register: gpu_info
changed_when: false
- name: Check used CPU
ansible.builtin.shell: sar 1 1 | grep "Average" | awk '{print 100-$8}'
@ -35,7 +25,6 @@
msg:
running: "{{ running_info.stdout_lines }}"
sys_mem: "{{ sys_mem_info.stdout_lines }}"
dev_mem: "{{ dev_mem_info.stdout_lines }}"
tpu: "{{ tpu_info.stdout }}"
gpu: "{{ gpu_info.stdout }}"
cpu: "{{ cpu_info.stdout }}"
containers_ids: "{{ containers_id.stdout_lines }}"

View file

@ -1,29 +1,9 @@
- name: Create model weights directory if it does not exist
ansible.builtin.file:
path: /data/weights/synapse-faces-weights
state: directory
mode: '0775'
- name: Run module
ansible.builtin.shell: docker run \
-d \
--rm \
--privileged=true \
-v /opt/sophon:/opt/sophon \
-v /etc/profile.d:/etc/profile.d \
-v /etc/ld.so.conf.d:/etc/ld.so.conf.d \
-v /data/weights/synapse-faces-weights:/server/data/weights/int8 \
-e DETECTOR_SIZE={{ size }} \
-e TZ="Europe/Moscow" \
-e MINIO_ENDPOINT="{{ MINIO_ENDPOINT }}" \
-e MINIO_ACCESS_KEY="{{ MINIO_ACCESS_KEY }}" \
-e MINIO_SECRET_KEY="{{ MINIO_SECRET_KEY }}" \
-e MINIO_PUB_CERT="{{ MINIO_PUB_CERT }}" \
-p {{ port }}:9000 \
--workdir /server \
--name faces_service_{{ port }} {{ image }} /bin/bash docker/tpu/entry.sh
register: run_info
- name: Run docker compose up
ansible.builtin.shell:
cmd: docker compose up -d
chdir: {{ path }}
register: run_info
changed_when: run_info.rc != 0
- name: Display run info
ansible.builtin.debug:

View file

@ -1,5 +1,7 @@
- name: Stop module
ansible.builtin.shell: docker stop faces_service_{{ module_port }}
ansible.builtin.command:
cmd: docker compose down
chdir: {{ path }}
register: stop_info
- name: Display stop info

View file

@ -2,7 +2,7 @@ version: '3.8'
services:
master-node:
build:
context: .
context: ./master-node
dockerfile: ./master-node/Dockerfile
ports:
- "5010:5010"

View file

@ -0,0 +1,8 @@
version: '3.8'
services:
master-node:
build:
context: .
dockerfile: Dockerfile
ports:
- "5010:5010"