48 lines
1.8 KiB
YAML
48 lines
1.8 KiB
YAML
---
|
|
# Ansible 探马 - 检查所有客户端节点的基础环境
|
|
- name: 侦察客户端节点基础环境
|
|
hosts: all
|
|
gather_facts: yes
|
|
tasks:
|
|
- name: 收集系统架构信息
|
|
debug:
|
|
msg: "节点 {{ inventory_hostname }} - 架构: {{ ansible_architecture }} - 系统: {{ ansible_distribution }} {{ ansible_distribution_version }}"
|
|
|
|
- name: 检查 HashiCorp 软件包安装状态
|
|
shell: |
|
|
echo "=== HashiCorp 软件包检查 ==="
|
|
echo "Nomad: $(nomad version 2>/dev/null || echo '未安装')"
|
|
echo "Consul: $(consul version 2>/dev/null || echo '未安装')"
|
|
echo "Vault: $(vault version 2>/dev/null || echo '未安装')"
|
|
register: hashicorp_status
|
|
|
|
- name: 检查 HashiCorp 软件源配置
|
|
shell: |
|
|
echo "=== 软件源配置检查 ==="
|
|
if [ -f /etc/apt/sources.list.d/hashicorp.list ]; then
|
|
echo "HashiCorp 源文件存在:"
|
|
cat /etc/apt/sources.list.d/hashicorp.list
|
|
else
|
|
echo "HashiCorp 源文件不存在"
|
|
fi
|
|
register: sources_status
|
|
|
|
- name: 检查系统服务状态
|
|
shell: |
|
|
echo "=== 系统服务状态 ==="
|
|
echo "Nomad: $(systemctl is-active nomad 2>/dev/null || echo '未配置')"
|
|
echo "Consul: $(systemctl is-active consul 2>/dev/null || echo '未配置')"
|
|
echo "Podman: $(systemctl is-active podman 2>/dev/null || echo '未配置')"
|
|
register: services_status
|
|
|
|
- name: 显示侦察结果
|
|
debug:
|
|
msg: |
|
|
==========================================
|
|
节点: {{ inventory_hostname }}
|
|
架构: {{ ansible_architecture }}
|
|
==========================================
|
|
{{ hashicorp_status.stdout }}
|
|
{{ sources_status.stdout }}
|
|
{{ services_status.stdout }}
|
|
========================================== |