Ansible Repo - 结构

时间:2016-02-03 15:11:47

标签: git ansible

Ansible建议的回购可以在以下网址看到: - http://docs.ansible.com/ansible/playbooks_best_practices.html

production                # inventory file for production servers
staging                   # inventory file for staging environment

group_vars/
   group1                 # here we assign variables to particular groups
   group2                 # ""
host_vars/
   hostname1              # if systems need specific variables, put them here
   hostname2              # ""

library/                  # if any custom modules, put them here (optional)
filter_plugins/           # if any custom filter plugins, put them here (optional)

site.yml                  # master playbook
webservers.yml            # playbook for webserver tier
dbservers.yml             # playbook for dbserver tier

roles/
    common/               # this hierarchy represents a "role"
        tasks/            #
            main.yml      #  <-- tasks file can include smaller files if warranted
        handlers/         #
            main.yml      #  <-- handlers file
        templates/        #  <-- files for use with the template resource
            ntp.conf.j2   #  <------- templates end in .j2
        files/            #
            bar.txt       #  <-- files for use with the copy resource
            foo.sh        #  <-- script files for use with the script resource
        vars/             #
            main.yml      #  <-- variables associated with this role
        defaults/         #
            main.yml      #  <-- default lower priority variables for this role
        meta/             #
            main.yml      #  <-- role dependencies

    webtier/              # same kind of structure as "common" was above, done for the webtier role
    monitoring/           # ""
    fooapp/               # ""

我的问题是这个回购的级别是什么 - 你是否为每个项目/应用程序都有这些格式之一,或者这是针对整个产业?

干杯

2 个答案:

答案 0 :(得分:0)

这取决于您的偏好和/或项目的大小/复杂程度。我认为将项目分隔在不同的存储库中是完全合理的。

如果你有多个项目使用的共同角色,你可以使用git子模块(如果你使用分支/分叉会很痛苦)或Ansible Galaxy来安装来自另一个repo的那些。

答案 1 :(得分:0)

我采用混合方法。每个团队/项目都有自己的空间,但我维护一个全局库存和一组与网络和数据中心基础设施相关的group_vars。

Ansible非常灵活,所以开始简单并将其塑造给您的特定团队和公司的工作方式。

相关问题