大网数据广告活动
服务器运维问答

How to run multiple playbooks in order with Ansible?

· 52CE 我爱测

I'm working on several Ansible playbooks to spin up a new server instance. There are approximately 15 different playbooks I need to run in a specific order to successfully spin up a server. My initial thought was to write a shell…

问题原文

原帖链接 · nulltek · CC BY-SA 3.0

I'm working on several Ansible playbooks to spin up a new server instance. There are approximately 15 different playbooks I need to run in a specific order to successfully spin up a server.

My initial thought was to write a shell script that executes ansible-playbook playbook_name.yml and duplicate it one entry for each playbook I need to run.

Is there a smarter/better way to do this using a master playbook and if so what would it look like (examples are appreciated).

I could write one monolithic playbook that does it all but there are some plays that run as root first then as a sudo user later.

已采纳解答

原帖链接 · flxPeters · CC BY-SA 3.0

Build many sub-playbooks and aggregate them via include statements.

- include: playbook-one.yml
- include: playbook-two.yml

If your playbooks must run in order and if all of them are mandatory, build a main playbook and include files with tasks. A playbook should always be a closed process.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。