我用pip安装了ansible
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
sudo pip install ansible但我在~/.ansible.cfg或etc/ansible中都找不到macOS。
$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如何找到或设置库存文件?
发布于 2019-11-21 10:11:38
发布于 2022-09-21 13:05:21
可以使用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
[ . . . ]注意事项:考虑安全性问题使用当前目录中的ansible.cfg避免安全风险。
以下是Ansible将搜索配置文件的位置的优先级列表(请参阅配置文件):
ANSIBLE_CONFIG (环境变量如果设置)ansible.cfg (在当前目录中)~/.ansible.cfg (在主目录中)/etc/ansible/ansible.cfghttps://stackoverflow.com/questions/58970811
复制相似问题