gpt4 book ai didi

ansible-2.x - Ansible 角色 : What content should I wtrite in `site.yml` and `webservers.yml` ?

转载 作者:行者123 更新时间:2023-12-02 01:08:35 25 4
gpt4 key购买 nike

文档中有一个角色目录结构示例( http://docs.ansible.com/ansible/latest/playbooks_reuse_roles.html#role-directory-structure )

Example project structure:


site.yml
webservers.yml
fooservers.yml
roles/
common/
tasks/
handlers/
files/
templates/
vars/
defaults/
meta/
webservers/
tasks/
defaults/
meta/

问题:
我应该写什么内容 site.ymlwebservers.yml ?

例如:

文档说( http://docs.ansible.com/ansible/latest/playbooks_reuse_roles.html#using-roles ),

The classic (original) way to use roles is via the roles: option for a given play:


- hosts: webservers
roles:
- common
- webservers


上面的内容可以放在哪个文件里?

最佳答案

根据文档示例,您将拥有:

网络服务器.yml:

- hosts: webservers
roles:
- common
- webservers

fooservers.yml:
- hosts: fooservers
roles:
- common
tasks:
- shell: /usr/bin/foo.sh

站点.yml:
- include: webservers.yml
- include: fooservers.yml

关于ansible-2.x - Ansible 角色 : What content should I wtrite in `site.yml` and `webservers.yml` ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46379544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com