gpt4 book ai didi

ansible - 找不到 ~/.ansible.cfg 或 etc/ansible

转载 作者:行者123 更新时间:2023-12-03 08:51:02 25 4
gpt4 key购买 nike

我使用 pip 安装了 ansible

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
sudo pip install ansible

但我在 macOS 中找不到 ~/.ansible.cfgetc/ansible

$ansible --version

WARNING: Executing a script that is loading libcrypto in an unsafe way. This will fail in a future version of macOS. Set the LIBRESSL_REDIRECT_STUB_ABORT=1 in the environment to force this into an error.
ansible 2.10.0.dev0
config file = None
configured module search path = [u'/Users/nethminiromina/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Users/nethminiromina/Library/Python/2.7/lib/python/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.16 (default, Oct 17 2019, 17:14:30) [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s

如何查找或设置库存文件?

最佳答案

您可以使用ansible-config显示配置文件位置

% ansible-config --version
ansible-config [core 2.13.1]
config file = None
configured module search path = ['/Users/myusername/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ansible
ansible collection location = /Users/myusername/.ansible/collections:/usr/share/ansible/collections
executable location = /Library/Frameworks/Python.framework/Versions/3.9/bin/ansible-config
python version = 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:39:15) [Clang 6.0 (clang-600.0.57)]
jinja version = 3.1.2
libyaml = True

在这种情况下,我没有配置文件 (config file = None),因此我生成了一个空配置文件(选项 --disabled 表示所有条目都被注释掉)当前目录与

% ansible-config init --disabled > ansible.cfg

现在ansible-config可以在当前目录/localDir找到配置文件

% ansible-config --version                    
ansible-config [core 2.13.1]
config file = /localDir/ansible.cfg
[ . . . ]

注意:考虑安全问题 Avoiding security risks with ansible.cfg in the current directory .

以下是 Ansible 将搜索配置文件的位置的优先级列表(请参阅 configuration file ):

  • ANSIBLE_CONFIG(环​​境变量,如果设置)
  • ansible.cfg(在当前目录中)
  • ~/.ansible.cfg(在主目录中)
  • /etc/ansible/ansible.cfg

关于ansible - 找不到 ~/.ansible.cfg 或 etc/ansible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58970811/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com