--- - name: 部署完整监控栈 hosts: localhost become: no vars: ansible_python_interpreter: /usr/bin/python3 tasks: - name: 停止并purge现有的monitoring-stack job command: nomad job stop -purge monitoring-stack register: stop_result failed_when: false changed_when: stop_result.rc == 0 - name: 等待job完全停止 pause: seconds: 5 - name: 部署完整的monitoring-stack job (Grafana + Prometheus + Loki) command: nomad job run /root/mgmt/infrastructure/monitor/monitoring-stack.nomad register: deploy_result - name: 显示部署结果 debug: msg: "{{ deploy_result.stdout_lines }}" - name: 等待服务启动 pause: seconds: 30 - name: 检查monitoring-stack job状态 command: nomad job status monitoring-stack register: status_result - name: 显示job状态 debug: msg: "{{ status_result.stdout_lines }}" - name: 检查Consul中的监控服务 command: consul catalog services register: consul_services - name: 显示Consul服务 debug: msg: "{{ consul_services.stdout_lines }}"