1. 程式人生 > 實用技巧 >Ansible配置檔案優先順序

Ansible配置檔案優先順序

[root@m01 ~]# vim /etc/ansible/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

[root@m01 
~]# rpm -ql ansible [root@m01 ~]# zcat /usr/share/man/man1/ansible-config.1.gz #要檢視完整列表,請訪問https://docs.ansibe.com/或使用ansibe-config命令。 For a full list check \fI\%https://docs.ansible.com/\fP\&. or use the \fIansible\-config\fP command. #/etc/ansible/ansible.cfg 配置檔案,如果存在則使用 /etc/ansible/ansible.cfg \-\- Config file, used if
present #~/.ansible.cfg 使用者配置檔案,覆蓋預設配置(如果存在) ~/.ansible.cfg \-\- User config file, overrides the default config if present #\&/ansible.cfg 本地配置檔案(在當前工作目錄中)假定為(aqproject-specific)(aq,如果存在,則重寫其餘檔案)。 \&./ansible.cfg \-\- Local config file (in current working directory) assumed to be \(aqproject specific\(aq and overrides the rest if
present. #如上所述,ANSIBLE_CONFIG環境變數將覆蓋所有其他環境變數。 As mentioned above, the ANSIBLE_CONFIG environment variable will override all others.

總結:

#生效優先順序
ANSIBLE_CONFIG >> $ANSIBLE_CONFIG/ansible.cfg >> ~/.ansible.cfg >> /etc/ansible/ansible.cfg