Ansible的配置文件:,Ansible配置文件:


Ansible的配置文件:

Ansible 的一些的设置可以通过配置文件完成,在大多数场景下默认的配置就能满足大多数用户的需求,

在一些特殊场景下,用户还是需要自行修改这些配置文件。


用户可以修改一下配置文件来修改设置,它们被读取的顺序如下:

* ANSIBLE_CONFIG (一个环境变量)
* ansible.cfg (位于当前目录中)
* .ansible.cfg (位于家目录中)
* /etc/ansible/ansible.cfg


环境配置:

Ansible通过环境变量的形式来进行配置,这些设置后的环境变量将会覆盖

所有配置文件读取的配置。

[root@node01 ansible]# cat ansible.cfg 
[defaults]
inventory      = /etc/ansible/hosts
sudo_user=root
remote_port=22
host_key_checking=False
remote_user=root
log_path=/var/log/ansible.log
module_name=command
private_key_file=/root/.ssh/id_rsa
no_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 >>
node2
Shared connection to 192.168.137.3 closed.

115.236.19.4 | SUCCESS | rc=0 >>
yun-bak
Shared connection to 115.236.19.4 closed.

192.168.137.1 | SUCCESS | rc=0 >>
TLCB-PC
Shared 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: 

相关内容

    暂无相关文章