ansible配置文件ansible.cfg

仅罗列了一些常用基本配置,更多配置详情请到ansible官方配置文件查看

https://docs.ansible.com/ansible/latest/reference_appendices/config.html

配置文件优先级

ANSIBLE_CONFIG   如果设置了该环境变量,则使用该环境变量指向的配置文件
.
/ansible.cfg 在当前目录中s搜索配置文件
~/.ansible.cfg 在当前用户的home目录下的配置文件
/etc/ansible/ansible.cfg ansible默认的配置文件

从上到下,优先级递减

ansible.cfg常用基本配置

[defaults]

#Ansible需要连接管理的主机列表hosts文件路径,默认/etc/ansible/hosts
inventory = /etc/ansible/hosts
#ansible role存放路径,默认/etc/ansible/roles
roles_path = /etc/ansible/roles
#Ansible日志路径,默认/var/log/ansible.log
log_path = /var/log/ansible.log


#SSH连接超时时间,默认10s
timeout = 10
#ansible第一次连接客户端是是否要检查ssh密钥
host_key_checking = False


#ansible执行并发数,默认5
forks = 5
#异步执行任务时查询间隔,默认15s
poll_interval = 15
#执行ansible命令时使用的用户,默认root
sudo_user = root
#远程主机SSH端口,默认22
remote_port = 22
#ansible执行playbook时远程认证用户,默认root
remote_user = root


#Ansible搜寻模块的位置,默认/usr/share/my_modules/
library = /usr/share/my_modules/
module_utils = /usr/share/my_module_utils/


#ansible模块运行语言环境,默认C
module_lang = C
module_set_locale = False
#ansible使用模块,默认command
module_name=command
原文地址:https://www.cnblogs.com/gudanaimei/p/13238083.html