我有一个名为" mysync"的模块。这是同步的一个小修改。这张票的底部是同步和mysync之间的差异。它被放在库目录中:
library = /sites/utils/local/ansible/modules
在Playbook中运行模块时,找不到该模块。建议?
@> cat play.yml
- hosts: all
name: put shop onto server
mysync:
mode: pull
module: shop
src: rsync://@DEPOTHOST@::shop.ear
dest: /sites/MODULES/
archive: no
compress: yes
copy_links: yes
delete: yes
links: yes
times: yes
use_ssh_args: yes
verify_host: no
delegate_to: "{{ inventory_hostname }}"
@>ansible-playbook ./sync_shop.yml --limit tst37 -vvv
ERROR! 'mysync' is not a valid attribute for a Play
The error appears to have been in '/sites/utils/local/ansible/modules/sync_shop.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- hosts: all
^ here
@>diff diff /Library/Python/2.7/site-packages/ansible/modules/files/synchronize.py ./mysync.py
26,28c26,28
< module: synchronize
< version_added: "1.4"
< short_description: A wrapper around rsync to make common tasks in your playbooks quick and easy.
---
> module: mySync
> version_added: "2.1"
> short_description: A custom wrapper around rsync to get src-host, src and dest from ldap
302a303,304
> import socket
> from ansible.module_utils.ldapData import ldapData
370a373,382
> #myInv = ldapData(self.args.debug,self.args.file,self.args.refresh)
> myInv = ldapData()
> host = socket.getfqdn()
> mydata = hosts[host][instances]
> for inst in mydata:
> if 'depothost' in inst:
> src_host=inst['depothost']
> if src_host is None:
> module.fail_json(msg='Could not determine depothost')
>
378a391
> source.replace('@DEPOTHOST@',src_host)
答案 0 :(得分:1)
您不应直接从游戏中“调用”模块(自定义或标准)。
您应该将它们添加到游戏中遗漏的tasks
词典中。
- hosts: all
tasks:
- name: put shop onto server
mysync:
mode: pull
module: shop
# etc.