【Ansible 文档】【译文】配置文件

这里说明一下配置文件的内容,原文地址:http://docs.ansible.com/ansible/latest/intro_configuration.html

这个与【Ansible 文档】配置 不一样,【Ansible 文档】配置 包含的是内容网址,而且其说明配置的方式和此处介绍的不一样。

这里说明的配置是配置文件: ansible.cfg

Configuration file 配置文件

Configuration file

Ansible中的某些配置可以通过配置文件调整。现有的配置在大多数情况下对于大多数用户都是足够的,但是在一些某些原因下,用户还是需要自行修改这些配置文件

配置文件中的配置修改和应用会按照如下的优先级顺序处理:

* ANSIBLE_CONFIG (an environment variable)
* ansible.cfg (in the current directory)
* .ansible.cfg (in the home directory)
* /etc/ansible/ansible.cfg

Ansible 1.5之前是:

* ansible.cfg (in the current directory)
* ANSIBLE_CONFIG (an environment variable)
* .ansible.cfg (in the home directory)
* /etc/ansible/ansible.cfg

Ansible会按照上述列表顺序查找,第一个配置文件将被使用。不会合并所有列表文件的内容。

注意:

  配置文件是ini格式的变种,当在行的首部注释时,可以通过 “#” 或者“;”。如果是在行中注释,只能用分号“;”,如下所示:

# some basic default values...
inventory = /etc/ansible/hosts  ; This points to the file that lists your hosts

Getting the latest configuration 获取最新的配置

如果你使用包管理器安装,最新的ansible.cfg会在/etc/ansible/目录中,并且命名为 ”.rpmnew”,也可能根据不同的更新命名为其它名称

如果你是通过 pip 或者其他方式安装,则可能需要自行创建这个文件,为了覆写Ansible中的默认配置。

你可以查看 ansible.cfg in source control来查看最新的配置模版,以及各个参数可能的值。

Environmental configuration 环境配置

Ansible同样支持通过环境变量配置。如果这些环境变量被设置,他们会覆写任何从配置文件中获得的配置。这些变量可以定义在: constants.py

可以查看 http://docs.ansible.com/ansible/latest/config.html 中的内容,里面有环境变量设置部分。

Explanation of values by section 按照section来解释配置

配置文件被分解为不同的section,大部分选项在default section,同时有些section特定一些连接插件的。

详细配置说明略。

General defaults

Privilege Escalation Settings

Paramiko Specific Settings

OpenSSH Specific Settings

Accelerated Mode Settings

Selinux Specific Settings

Galaxy Settings

原文地址:https://www.cnblogs.com/pengyusong/p/7692400.html