在ansible文档intro_configuration中,据说:
Ansible ......它还会在"./library"目录中查找与剧本一起的模块.
在我的情况下,我获得指令提供的唯一方法gaqzi.ssh-config是由ansible看到显式导出带有完整路径的ANSIBLE_LIBRARY;(
如果没有该gaqzi.ssh-config模块,ansible就找不到该文件.
在这里我要做的就是让它工作::
$ cd playbook # my folder were the plabooks are
$ ansible-galaxy install -p library gaqzi.ssh-config # I get a lib
$ export ANSIBLE_LIBRARY=/home/me/full/path/to/the/above/playbook/library
$ # the export above is annoying
Run Code Online (Sandbox Code Playgroud)
我如何动态检查地点Ansible真的在寻找'图书馆'?
PS1:我正在使用ansible 2.0和vagrant 1.8.1 ::
$ vagrant --version
Vagrant 1.8.1
$ ansible --version
ansible 2.0.0.2
config file = /etc/ansible/ansible.cfg
$
Run Code Online (Sandbox Code Playgroud)
PS2:我小心删除所有ansible.cfg/.ansible.cfg文件,除了ubuntu提供的文件 /etc/ansible/ansible.cfg
Ansible实际上在current_playbook/library目录中搜索.
您可以使用以下设置对此进行测试:
将其custom_module.py放入librarysubdir中:
#!/usr/bin/python
import json
print json.dumps({"hello" : "world"})
Run Code Online (Sandbox Code Playgroud)制作以下test.yml剧本:
---
- hosts: localhost
tasks:
- name: custom module
custom_module:
Run Code Online (Sandbox Code Playgroud)执行 ansible-playbook -vv test.yml
随ansible-galaxy你安装角色,而不是模块.用于定义的
参数.-pansible-galaxyROLE_PATH
如果您只想要角色中的模块ssh_config,则
需要将from 复制到.gaqzi.ssh-configssh_config.pycurrent_playbook/library/gaqzi.ssh-config/librarycurrent_playbook/library
或者,您可以按预期将gaqzi.ssh-config角色安装到roles目录中.
然后通过添加以下内容修改您的剧本以应用此角色:
roles:
- gaqzi.ssh-config
Run Code Online (Sandbox Code Playgroud)
应用此角色后,模块ssh_config将在您的剧本中可用.
| 归档时间: |
|
| 查看次数: |
4487 次 |
| 最近记录: |