Files
awoooi/infra/ansible/roles/pm2-service/tasks/main.yml
OG T 0139aa79e7 feat(infra): B-1 Ansible Host IaC 骨架完整版
- roles/nginx/templates/188-all-sites.conf.j2: 8 個服務 Jinja2 模板
- roles/docker-compose-service/tasks/main.yml: 通用 Docker Compose role
- roles/swap/tasks/main.yml: swap2.img 管理 role (110 專用)
- roles/pm2-service/tasks/main.yml: PM2 process 狀態確認 role
- .gitea/workflows/ansible-lint.yml: infra/ansible/** 異動自動 lint

Sprint B-1 完成: Git = 唯一真相 (Host IaC 骨架)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 02:47:10 +08:00

23 lines
855 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
# pm2-service role — 確保 PM2 管理的服務運作中
# 呼叫方式: include_role: name=pm2-service
# vars:
# pm2_app_name: wooo-aiops # PM2 process name
# pm2_user: wooo # 執行 PM2 的使用者
- name: "{{ pm2_app_name }} | 確認 PM2 process 狀態"
ansible.builtin.command:
cmd: "pm2 jlist"
become_user: "{{ pm2_user }}"
register: pm2_list
changed_when: false
- name: "{{ pm2_app_name }} | 解析 process 狀態"
ansible.builtin.set_fact:
_pm2_online: "{{ (pm2_list.stdout | from_json | selectattr('name', 'equalto', pm2_app_name) | selectattr('pm2_env.status', 'equalto', 'online') | list | length) > 0 }}"
- name: "{{ pm2_app_name }} | 警告:服務未 online"
ansible.builtin.debug:
msg: "⚠️ PM2 process '{{ pm2_app_name }}' 未 online請手動檢查"
when: not _pm2_online