Ansible 将剧本纳入主剧本

Ansible 将剧本纳入主剧本,ansible,Ansible,如何将儿童剧本纳入主剧本?子playbook包含多个主机组 示例:child-sample.yml - hosts: webservers remote_user: root - tasks: name: ensure apache is at the latest version yum: name=httpd state=latest name: write the apache config file template: src=/srv/htt

如何将儿童剧本纳入主剧本?子playbook包含多个主机组

示例:child-sample.yml

- hosts: webservers
  remote_user: root

  - tasks:
    name: ensure apache is at the latest version
    yum: name=httpd state=latest

    name: write the apache config file
    template: src=/srv/httpd.j2 dest=/etc/httpd.conf

- hosts: databases
  remote_user: root

  - tasks:
    name: ensure postgresql is at the latest version 
    yum: name=postgresql state=latest

    name: ensure that postgresql is started
    service: name=postgresql state=started

master-sample.yml应该如何包含这样的儿童游戏书?

它非常简单:

master-sample.yaml:

- include: child-sample.yml
- include: child-sample2.yml

如果child-sample1.yml对于问题中所示的不同任务有不同的主机组,该怎么办?这没关系。包括剧本本质上与将其内容复制粘贴到一个大文件相同。Ansible然后逐个播放进行处理,根据当前库存检查播放的主机模式,并在匹配的服务器上执行任务。@KonstantinSuvorov如何使用include方法将相同的变量传递给两个子播放(覆盖子播放中的值)?