diff --git a/ansible-deploy b/ansible-deploy index 499b57f..e6a946e 100755 Binary files a/ansible-deploy and b/ansible-deploy differ diff --git a/internal/services/ansible.go b/internal/services/ansible.go index 84961b2..6f2a5b4 100644 --- a/internal/services/ansible.go +++ b/internal/services/ansible.go @@ -275,6 +275,12 @@ func (s *AnsibleService) ListGroups() []models.HostGroup { // 动态展开组内主机(通过 host.Groups 字段关联,而非 group.Hosts) var hostList []models.Host for _, h := range s.hosts { + if gcopy.Name == "all" { + // all 组包含所有主机 + hcopy := *h + hostList = append(hostList, hcopy) + continue + } for _, hGroup := range h.Groups { if hGroup == gcopy.Name { hcopy := *h @@ -282,7 +288,7 @@ func (s *AnsibleService) ListGroups() []models.HostGroup { break } } - // 也检查主机的默认组(all/ungrouped) + // 也检查主机的默认组(ungrouped) if len(h.Groups) == 0 && gcopy.Name == "ungrouped" { hcopy := *h hostList = append(hostList, hcopy) diff --git a/inventory/hosts.json b/inventory/hosts.json index 7a5f4fd..79c6ec2 100644 --- a/inventory/hosts.json +++ b/inventory/hosts.json @@ -1,34 +1,4 @@ [ - { - "id": "57884720", - "name": "scmp46", - "ip": "172.16.11.42", - "port": 22, - "username": "root", - "password": "STC#scmp%0818", - "groups": [ - "zebu_user01" - ], - "status": "online", - "last_check": "2026-05-13T18:30:38.103119534+08:00", - "created_at": "0001-01-01T00:00:00Z", - "updated_at": "2026-05-13T18:28:16.71131472+08:00" - }, - { - "id": "5150c740", - "name": "scmp47", - "ip": "172.16.11.44", - "port": 22, - "username": "root", - "password": "STC#scmp%0818", - "groups": [ - "zebu_user01" - ], - "status": "online", - "last_check": "2026-05-13T18:30:33.343216547+08:00", - "created_at": "0001-01-01T00:00:00Z", - "updated_at": "2026-05-13T18:28:08.656450224+08:00" - }, { "id": "706f8ce7", "name": "nas", @@ -58,5 +28,35 @@ "last_check": "2026-05-13T18:27:19.272543838+08:00", "created_at": "0001-01-01T00:00:00Z", "updated_at": "2026-05-13T18:23:27.433461112+08:00" + }, + { + "id": "57884720", + "name": "scmp46", + "ip": "172.16.11.42", + "port": 22, + "username": "root", + "password": "STC#scmp%0818", + "groups": [ + "zebu_user01" + ], + "status": "online", + "last_check": "2026-05-13T18:30:38.103119534+08:00", + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "2026-05-13T18:28:16.71131472+08:00" + }, + { + "id": "5150c740", + "name": "scmp47", + "ip": "172.16.11.44", + "port": 22, + "username": "root", + "password": "STC#scmp%0818", + "groups": [ + "zebu_user01" + ], + "status": "online", + "last_check": "2026-05-13T18:30:33.343216547+08:00", + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "2026-05-13T18:28:08.656450224+08:00" } ] \ No newline at end of file diff --git a/playbooks/check-cpu-mem-disk.yml b/playbooks/check-cpu-mem-disk.yml index 7c863c6..993591c 100644 --- a/playbooks/check-cpu-mem-disk.yml +++ b/playbooks/check-cpu-mem-disk.yml @@ -48,6 +48,6 @@ when: cpu_usage | int >= crit_threshold - name: 警告判断 - warn: - msg: "{{ inventory_hostname }} CPU 使用率超过 {{ warn_threshold }}%: {{ cpu_usage }}%" + debug: + msg: "⚠️ WARNING: {{ inventory_hostname }} CPU 使用率超过 {{ warn_threshold }}%: {{ cpu_usage }}%" when: cpu_usage | int >= warn_threshold and cpu_usage | int < crit_threshold