目录
参考
配置优先级
配置参数说明
Written by Zak Zhu
参考
Breeze Yan 老师博客 https://www.cnblogs.com/breezey/
Breeze Yan 老师 GitHub 网址 https://github.com/yanruogu
配置优先级
配置文件: ansible.cfg
优先级: 配置
ANSIBLE_CONFIG:ansible 命令会先检查该环境变量
./ansible.cfg: 当前执行 ansible 命令的目录
~/.ansible.cfg
/etc/ansible/ansible.cfg: 默认配置文件
注意: 配置文件中所有的配置项都可以通过环境变量的方式来定义, 而环境变量定义的配置项具有最高优先级, 会覆盖掉所有配置文件中的配置项
上述结论, 可以从 ansible.cfg 文件的开头注释中看到:
- # nearly all parameters can be overridden in ansible-playbook
- # or with command line flags. ansible will read ANSIBLE_CONFIG,
- # ansible.cfg in the current working directory, .ansible.cfg in
- # the home directory or /etc/ansible/ansible.cfg, whichever it
- # finds first
配置参数说明
- [defaults]
- #inventory = /etc/ansible/hosts
- #library = /usr/share/my_modules/
- #module_utils = /usr/share/my_module_utils/
- #remote_tmp = ~/.ansible/tmp
- #local_tmp = ~/.ansible/tmp
- #plugin_filters_cfg = /etc/ansible/plugin_filters.YAML
- forks = 20 # 该值需经过测试后设定
- #poll_interval = 15
- #sudo_user = root
- #ask_sudo_pass = True
- ask_pass = False
- #transport = smart
- #remote_port = 22
- #module_lang = C
- #module_set_locale = False
- ## 使用 JSON 文件作为 fact 缓存后端
- gathering = smart
- fact_caching_timeout = 86400
- fact_caching = jsonfile
- fact_caching_connection = /tmp/ansible_fact_cache
- #roles_path = /etc/ansible/roles
- ## SSH 过期时间
- timeout = 60
- host_key_checking = False
- ## 被控端提权的普通用户
- remote_user = ansible
- log_path = /var/log/ansible.log
- [inventory]
- ### 与主机清单相关的配置
- [privilege_escalation]
- become=True
- become_method=sudo
- become_user=root
- become_ask_pass=False
- [paramiko_connection]
- ### Paramiko 在 RHEL6 以及更早的版本中默认使用的 SSH 连接方式
- [ssh_connection]
- ### OpenSSH 是 Ansible 在 RHEL7 中默认使用的 SSH 连接方式
- ### 调优配置如下:
- ssh_args = -C -o ControlMaster=auto -o ControlPersist=10m -o StrictHostKeyChecking=no
- ## 开启 pipelining, 并在被控端的 / etc/sudoers 文件中关闭 requiretty!
- pipelining = True
- [persistent_connection]
- ### 持久连接的配置项
- [accelerate]
Ansible 官方建议在可以使用 pipelining 的情况下, 尽量使用 pipelining 而不是 accelerate 模式. accelerate 只在如下情况下有用处:
管理 centos6 或者更早的那些依然使用 paramikio 作为连接被控节点的场景
无法使用 pipelining 的场景
- [selinux]
- ### selinux 相关的配置项
- [colors]
- ### ansible 命令输出的颜色相关的配置项
- [diff]
- ### 打印文件修改前后差异
来源: https://www.cnblogs.com/zakzhu/p/11633057.html