Ansible的配置文件:

来源:互联网 发布:linux printf 串口 编辑:程序博客网 时间:2024/06/01 17:29
Ansible的配置文件:Ansible 的一些的设置可以通过配置文件完成,在大多数场景下默认的配置就能满足大多数用户的需求,在一些特殊场景下,用户还是需要自行修改这些配置文件。用户可以修改一下配置文件来修改设置,它们被读取的顺序如下:* ANSIBLE_CONFIG (一个环境变量)* ansible.cfg (位于当前目录中)* .ansible.cfg (位于家目录中)* /etc/ansible/ansible.cfg环境配置:Ansible通过环境变量的形式来进行配置,这些设置后的环境变量将会覆盖所有配置文件读取的配置。[root@node01 ansible]# cat ansible.cfg [defaults]inventory      = /etc/ansible/hostssudo_user=rootremote_port=22host_key_checking=Falseremote_user=rootlog_path=/var/log/ansible.logmodule_name=commandprivate_key_file=/root/.ssh/id_rsano_log:True[root@node01 ansible]# [root@node01 ansible]# ansible webservers -m raw -a "hostname"              [DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.192.168.137.3 | SUCCESS | rc=0 >>node2Shared connection to 192.168.137.3 closed.115.236.19.4 | SUCCESS | rc=0 >>yun-bakShared connection to 115.236.19.4 closed.192.168.137.1 | SUCCESS | rc=0 >>TLCB-PCShared connection to 192.168.137.1 closed.ansible_managed:ask_pass这个可以控制,Ansible 剧本playbook 是否会自动默认弹出弹出密码.默认为no::ask_pass=True如果使用SSH 密钥匙做身份认证.可能需要修改这一参数[root@node01 ansible]# ansible webservers -m raw -a "hostname"[DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.SSH password: 

原创粉丝点击