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)}' ansible.builtin.shell: free -m | awk 'NR==2{printf "%d", ($2-$3)}'
register: sys_mem_info register: sys_mem_info
- name: Delete bm-smi log - name: Check used GPU
ansible.builtin.shell: rm -f bm-smi.log ansible.builtin.shell: |
register: del_file nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total --format=csv,noheader,nounits
register: gpu_info
- name: Save bm-smi log changed_when: false
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 CPU - name: Check used CPU
ansible.builtin.shell: sar 1 1 | grep "Average" | awk '{print 100-$8}' ansible.builtin.shell: sar 1 1 | grep "Average" | awk '{print 100-$8}'
@ -35,7 +25,6 @@
msg: msg:
running: "{{ running_info.stdout_lines }}" running: "{{ running_info.stdout_lines }}"
sys_mem: "{{ sys_mem_info.stdout_lines }}" sys_mem: "{{ sys_mem_info.stdout_lines }}"
dev_mem: "{{ dev_mem_info.stdout_lines }}" gpu: "{{ gpu_info.stdout }}"
tpu: "{{ tpu_info.stdout }}"
cpu: "{{ cpu_info.stdout }}" cpu: "{{ cpu_info.stdout }}"
containers_ids: "{{ containers_id.stdout_lines }}" containers_ids: "{{ containers_id.stdout_lines }}"

View file

@ -1,29 +1,9 @@
- name: Create model weights directory if it does not exist - name: Run docker compose up
ansible.builtin.file: ansible.builtin.shell:
path: /data/weights/synapse-faces-weights cmd: docker compose up -d
state: directory chdir: {{ path }}
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 register: run_info
changed_when: run_info.rc != 0
- name: Display run info - name: Display run info
ansible.builtin.debug: ansible.builtin.debug:

View file

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

View file

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

View file

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