2017-08-09 4 views
0

マスタープレイブックに子プレイブックを含めるにはどうすればよいですか?子脚本複数のホストグループにマスターブックにプレイブックを含める

例が含まれています。子供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 

はどのようにマスターsample.ymlは、このような子どもの脚本を含めるようにすべきですか?

答えて

1

それと同じくらい簡単です:

マスター-sample.yaml:

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

質問に示すように、子-sample1.ymlが異なるタスクのための別のホストグループを持っている場合は何? –

+0

それは問題ではありません。プレイブックを含むコンテンツは、コンテンツを1つの大きなファイルにコピー・ペーストすることと本質的に同じです。それから、Anipalは演劇でそれを処理し、現在の目録に対して演劇のホストパターンをチェックし、一致するサーバ上でタスクを実行する。 –

関連する問題