Rebuild validator-agent; ansible role checks traceroute and new settings

The role warns about new variables missing from the env file and, after
the container starts, checks that traceroute is installed and the agent
config has the retry and traceroute settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Opus 5.5 committed 2026-11-02 22:45:22 +03:00
1 parent 5c75ece8b1
commit 65c6975a24
7 files changed
+155 -5

No files matched your search

@@ -26,6 +26,44 @@
Контейнер {{ container_name }} в состоянии «{{ container_state.stdout }}»
(ожидалось: запущен, 0 перезапусков, образ {{ built_image.stdout }}).
quiet: true
# Трассировка: пакет traceroute ставится в образе (Dockerfile).
- name: Check that traceroute exists in the container
ansible.builtin.command: "docker exec {{ container_name }} sh -c 'command -v traceroute'"
register: traceroute_bin
changed_when: false
failed_when: false
- name: Assert traceroute is installed
ansible.builtin.assert:
that: traceroute_bin.rc == 0
fail_msg: >-
traceroute не найден в контейнере {{ container_name }}: образ собран из старой ревизии
(проверьте deploy_ref и что коммит запушен).
quiet: true
# Итоговый конфиг рендерит docker-entrypoint.sh из шаблона образа.
- name: Read the rendered agent config
ansible.builtin.command: "docker exec {{ container_name }} cat /etc/validator-agent/validator-agent.yaml"
register: agent_config
changed_when: false
failed_when: false
- name: Assert the config has retry and traceroute settings
ansible.builtin.assert:
that:
- agent_config.rc == 0
- "'https_attempts:' in agent_config.stdout"
- "'traceroute:' in agent_config.stdout"
fail_msg: >-
В конфиге агента нет https_attempts / traceroute: запущен образ из старой ревизии
(проверьте deploy_ref и что коммит запушен).
quiet: true
- name: Extract the new settings for the summary
ansible.builtin.set_fact:
agent_https_attempts: "{{ agent_config.stdout | regex_search('https_attempts:\\s*(\\d+)', '\\1') | default(['?'], true) | first }}"
agent_traceroute_enabled: "{{ agent_config.stdout | regex_search('traceroute:\\s*enabled:\\s*(\\S+)', '\\1') | default(['?'], true) | first }}"
rescue:
- name: Collect the container log
ansible.builtin.command: "docker logs --tail 30 {{ container_name }}"
@@ -62,4 +100,5 @@
ansible.builtin.debug:
msg: >-
{{ inventory_hostname }} ({{ effective_validator_id }}): {{ deploy_rev }} ({{ deploy_ref }}),
образ {{ built_image.stdout[:19] }}, контейнер {{ container_name }} запущен
образ {{ built_image.stdout[:19] }}, контейнер {{ container_name }} запущен,
попыток HTTPS: {{ agent_https_attempts }}, трассировка: {{ agent_traceroute_enabled }}