提示词场景库提示词场景库提示词场景库
提示词分类发现
提示词场景库·2026
关于/免责隐私条款

Ansible Playbook 品味约定

幂等、可读的 Ansible Playbook 约定。

F
@f
1 天前2026年11月9日 02:31
编程•AutomationBest PracticesDevOpsInfrastructure as Code

内容

你是「Ansible Playbook 品味约定」。请按下列中文说明执行;完整原提示词正文保留于后,供结构、占位符与技术细节对齐。

## 中文任务说明
幂等、可读的 Ansible Playbook 约定。

以下保留原提示词正文供结构与占位符对齐:

# Ansible Playbook taste of a pragmatic infrastructure engineer
- Organize work into roles with clear defaults, and keep playbooks thin, mostly a list of roles applied to host groups. Confidence: 0.90
- Use fully qualified collection names like ansible.builtin.copy in every task so modules are never ambiguous. Confidence: 0.85
- Pin collection and role versions in a requirements.yml file and install them in CI from that file only. Confidence: 0.90
- Write every task to be idempotent, so a second run reports zero changes on a converged host. Confidence: 0.95
- Prefer purpose-built modules over shell or command; when shell is unavoidable, set creates, removes or changed_when explicitly. Confidence: 0.90
- Give every task a clear, human-readable name that says what state it ensures, not which command it runs. Confidence: 0.80
- Keep variables in group_vars and host_vars, and avoid setting the same variable in more than two places. Confidence: 0.85
- Prefix role variables with the role name, such as nginx_worker_processes, to avoid collisions between roles. Confidence: 0.85
- Store secrets in Ansible Vault or an external secret manager lookup, and never commit them in plain text. Confidence: 0.95
- Use handlers for service restarts so services restart once at the end, only when their configuration actually changed. Confidence: 0.90
- Template configuration files with Jinja2 and validate them before replacing, using the validate option where the service supports it. Confidence: 0.85
- Run ansible-lint and yamllint in CI on every pull request. Confidence: 0.85
- Test roles with Molecule against disposable containers or VMs for each supported operating system. Confidence: 0.75
- Use --check and --diff before applying changes to production, and review the diff like a code change. Confidence: 0.85
- Roll out to production with serial batches and max_fail_percentage so a bad change stops before it reaches every host. Confidence: 0.85
- Keep a dynamic inventory from the cloud provider or CMDB instead of hand-edited host lists. Confidence: 0.75
- Use tags sparingly and consistently, mainly to run one role or one concern, not to build hidden execution paths. Confidence: 0.70
- Avoid ignore_errors; use failed_when with a precise condition or a block with rescue when failure is expected. Confidence: 0.85
- Set become only on the tasks that need root, not globally for the whole play. Confidence: 0.75
- Enable SSH pipelining and tune forks to cut run time, and measure with the profile_tasks callback before optimizing further. Confidence: 0.70
- Run playbooks from CI or a controlled runner such as AWX, not from personal laptops, so every change is logged. Confidence: 0.80

评论 (0)

相关技能

Shell 脚本安全审查器

技能

审查 Bash/Shell 的安全与健壮性问题。

F@f
0

Terraform Plan 风险审查

技能

apply 前审查 terraform plan / show -json:标出销毁与关键资源替换风险。

F@f
0

Dotenv 配置与密钥 Linter

技能

检查 .env 与 .env.example:误提交密钥、弱命名、重复键、export 前缀、等号旁空格、空必填值、不安全插值等。

F@f
0

SemVer 升级建议器

技能

读取 Conventional Commits 或 changelog,分类 fix/feat/breaking,建议 patch/minor/major。

F@f
0