由于 Ansible2.0.0.2 出现了’NoneType’对象没有’send_callback’属性的错误,因此对–list-tasks进行了修正
2系发布了,所以我决定尝试一下Ansible并开始了教程。但在进行教程时,我遇到了一个’NoneType’ object has no attribute ‘send_callback’的例外错误,于是我稍微做了一些调查。
顺便提一下,这是正在尝试的教程链接:(http://yteraoka.github.io/ansible-tutorial/)
我遇到的问题是确认任务清单中按照最佳实践进行构建的部分。
$ ansible --version
ansible 2.0.0.2
config file = /home/vagrant/ansible/ansible.cfg
configured module search path = Default w/o overrides
$ ansible-playbook --list-tasks -i test_servers site.yml
Unexpected Exception: 'NoneType' object has no attribute 'send_callback'
to see the full traceback, use -vvv
# -vvvオプションで例外の詳細を出してみる
$ ansible-playbook --list-tasks -i test_servers site.yml -vvv
2 plays in site.yml
Unexpected Exception: 'NoneType' object has no attribute 'send_callback'
the full traceback was:
Traceback (most recent call last):
File "/home/vagrant/.pyenv/versions/ansible2/bin/ansible-playbook", line 85, in <module>
sys.exit(cli.run())
File "/home/vagrant/.pyenv/versions/2.7.10/envs/ansible2/lib/python2.7/site-packages/ansible/cli/playbook.py", line 150, in run
results = pbex.run()
File "/home/vagrant/.pyenv/versions/2.7.10/envs/ansible2/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 115, in run
self._tqm.send_callback('v2_playbook_on_vars_prompt', vname, private, prompt, encrypt, confirm, salt_size, salt, default)
AttributeError: 'NoneType' object has no attribute 'send_callback'
在`playbook_executor.py`的第115行似乎发生了错误。
我通过搜索很快找到了相关的问题。
https://github.com/ansible/ansible/issues/12682
听说如果加上check或list类的选项,似乎会崩溃。
修正是根据这里的参考进行的:
https://github.com/ansible/ansible/commit/76feba00c4724e930c8c6fc7eba7e4a29c86cc3c
修正后执行后,任务列表成功显示。(但是,感觉与教程网站的显示有很大的不同…可能是因为是2系,也可能是因为从git上没有获取文件,而是手写的,可能弄错了…)
$ ansible-playbook --list-tasks -i test_servers site.yml -vvv
Using /home/vagrant/ansible/ansible.cfg as config file
2 plays in site.yml
playbook: site.yml
play #1 (all): TAGS: []
tasks:
include TAGS: []
include TAGS: []
include TAGS: []
include TAGS: []
play #2 (wordpress): TAGS: []
tasks:
在大型更新之后,会出现这种问题呢。
因为已经集成到stable-2.0分支中,所以很快就会发布修正版,不过我没有过投稿的经验,所以就像是工作备忘录一样发布了。