如何在ansible.cfg文件中添加几个库路径

时间:2018-08-31 17:23:09

标签: python ansible library-path

我已经使用pip安装了napalm-ansible,现在尝试将napalm-ansible库路径添加到我的ansible.cfg文件中。

root@usvr-1804:/home/labadmin# napalm-ansible
To ensure Ansible can use the NAPALM modules you will have
to add the following configurtion to your Ansible configuration
file (ansible.cfg):

[defaults]
library = /usr/local/lib/python2.7/dist-packages/napalm_ansible/modules
action_plugins = /usr/local/lib/python2.7/dist 
packages/napalm_ansible/plugins/action

但是我的ansible.cfg文件已经具有库路径。

root@usvr-1804:/home/labadmin# cat ansible.cfg

[defaults]
inventory = ./hosts
library = /etc/ansible/roles/PaloAltoNetworks.paloaltonetworks
host_key_checking = false
timeout = 5
log_path = /var/log/ansible.log
roles_path = /etc/ansible/roles

如何将第二个库路径添加到ansible.cfg文件中。谢谢

2 个答案:

答案 0 :(得分:1)

转到the docs for the Ansible Configuration Settings ,找到正确的参数library

  

library用冒号分隔的路径,Ansible将在其中搜索模块。

然后进行相应配置:

library = /etc/ansible/roles/PaloAltoNetworks.paloaltonetworks:/usr/local/lib/python2.7/dist-packages/napalm_ansible/modules

答案 1 :(得分:0)

您可以在library参数中添加任意数量的路径,只需在每个路径(documentation)之间放置一个冒号

library = /foo/bar:/foo/baz