Files
ansible-playbook/llmdoc/reference/ansible-modules-used.md
Wang Defa 167fad20eb 添加 Nezha Agent 管理功能和完整文档系统
- 新增 Nezha Agent client_secret 更新 playbook(两种实现方案)
- 建立三层文档架构:docs/(用户文档)、examples/(配置示例)、llmdoc/(技术文档)
- 添加项目主 README.md 和配置示例文件
- 初始化 .gitignore 保护敏感信息
2025-12-16 10:52:38 +08:00

47 lines
1.1 KiB
Markdown
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.
# Ansible 模块参考
## 核心模块列表
### 1. ansible.builtin.set_fact
- **用途**:动态构建和设置变量
- **示例**`ansible.builtin.set_fact: install_command="..."`
### 2. ansible.builtin.debug
- **用途**:输出调试信息和变量
- **关键参数**
- `msg`:直接打印消息
- `var`:打印变量值
### 3. ansible.builtin.get_url
- **用途**:从远程 URL 下载文件
- **关键参数**
- `url`:文件源地址
- `dest`:目标路径
- `mode`:文件权限
### 4. ansible.builtin.shell
- **用途**:执行复杂的 Shell 命令
- **注意事项**
-`command` 模块更灵活
- 支持管道和重定向
### 5. ansible.builtin.file
- **用途**:文件和目录管理
- **常用状态**
- `present`:确保文件存在
- `absent`:确保文件不存在
- `directory`:确保目录存在
## 使用场景映射
- 文件下载:`get_url`
- 动态参数:`set_fact`
- 命令执行:`shell`
- 日志记录:`debug`
- 文件清理:`file`
## 最佳实践提示
1. 优先使用专用模块
2. 谨慎使用 `shell` 模块
3. 始终关注安全性和幂等性