---
- include_tasks: utils/once/flag.yml
- name: "π Stage the MCP adapter instance for {{ application_id }}"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/svc-ai-mcp-adapter/tasks/instance.yml') }}"
vars:
mcp_adapter_instance_dir: "{{ PROMETHEUS_MCP_INSTANCE_DIR }}"
when: PROMETHEUS_MCP_ENABLED | bool
- name: "π§© Load the container CLI the data root probe calls"
include_role:
name: sys-svc-container
public: false
when: run_once_sys_svc_container is not defined
- name: "π Read the docker data root cAdvisor has to bind"
ansible.builtin.command: container info --format '{{ "{{" }}.DockerRootDir{{ "}}" }}'
register: prometheus_docker_info
changed_when: false
delegate_to: "{{ STACK_HOST }}"
- name: "π§© load docker and proxy for '{{ application_id }}'"
include_role:
name: sys-stk-backend
vars:
compose_handlers_flush: false
- name: "π Ensure the node-exporter textfile directory exists"
ansible.builtin.file:
path: "{{ DIR_METRICS_TEXTFILE }}"
state: directory
mode: "0755"
- name: "π Render Prometheus config files (local + swarm peers)"
ansible.builtin.include_tasks:
file: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/render_replicated_templates.yml') }}"
vars:
role_templates:
- src: "configuration/prometheus.yml.j2"
dest: "{{ PROMETHEUS_CONFIG_HOST }}"
mode: "0644"
- src: "configuration/blackbox.yml.j2"
dest: "{{ BLACKBOX_CONFIG_HOST }}"
mode: "0644"
- src: "configuration/alertmanager.yml.j2"
dest: "{{ ALERTMANAGER_CONFIG_HOST }}"
mode: "0644"
- src: "configuration/alert_rules.yml.j2"
dest: "{{ ALERT_RULES_CONFIG_HOST }}"
mode: "0644"
- name: "π Pre-create native-metrics docker networks (idempotent)"
include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/network/create.yml') }}"
vars:
network_role_id: "{{ metrics_app }}"
loop: "{{ lookup('native_metrics_apps') }}"
loop_control:
loop_var: metrics_app
- name: "πΏ flush handlers for '{{ application_id }}'"
meta: flush_handlers
- name: "π Include role sys-stk-front-proxy for '{{ application_id }}'"
include_role:
name: sys-stk-front-proxy
vars:
domain: "{{ lookup('domain', application_id) }}"
http_port: "{{ lookup('config', application_id, 'services.prometheus.ports.local.http') }}"
- name: "π Deploy prometheus nginx http-block config"
stack_host_template:
src: "roles/web-app-prometheus/templates/nginx/prometheus.conf.j2"
dest: "{{ [ lookup('nginx','directories.configuration.global'), 'prometheus.conf' ] | path_join }}"
notify: reload-openresty
- name: "π§± Rebuild the MCP adapter of {{ application_id }}"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/svc-ai-mcp-adapter/tasks/rebuild.yml') }}"
when: PROMETHEUS_MCP_ENABLED | bool
- name: "πΏ Flush compose handlers for {{ application_id }}"
ansible.builtin.meta: flush_handlers