我正在尝试在 ansible playbook 中运行一项任务,如下所示。
- name: Add user to a group
user:
name: "{{ansible_user}}"
groups: docker
append: yes
become: yes
when: node_type == "peer"
我正在使用 macOS 并且已经安装了 ansible 和 sshpass。我可以在远程 linux 机器上通过 ansible 运行不同的任务,但是当运行这个组任务时,我收到错误为'Connection' object has no attribute 'ssh' ansible
.
请指导我可能是什么问题?
编辑:追溯问题
ERROR! Unexpected Exception, this is probably a bug: 'Connection' object has no attribute 'ssh'
the full traceback was:
Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook", line 118, in <module>
exit_code = cli.run()
File "/Library/Python/2.7/site-packages/ansible/cli/playbook.py", line 122, in run
results = pbex.run()
File "/Library/Python/2.7/site-packages/ansible/executor/playbook_executor.py", line 156, in run
result = self._tqm.run(play=play)
File "/Library/Python/2.7/site-packages/ansible/executor/task_queue_manager.py", line 291, in run
play_return = strategy.run(iterator, play_context)
File "/Library/Python/2.7/site-packages/ansible/plugins/strategy/linear.py", line 267, in run
results.extend(self._execute_meta(task, play_context, iterator, host))
File "/Library/Python/2.7/site-packages/ansible/plugins/strategy/__init__.py", line 1098, in _execute_meta
connection.reset()
File "/Library/Python/2.7/site-packages/ansible/plugins/connection/paramiko_ssh.py", line 539, in reset
self.close()
File "/Library/Python/2.7/site-packages/ansible/plugins/connection/paramiko_ssh.py", line 606, in close
self.ssh.close()
AttributeError: 'Connection' object has no attribute 'ssh'
编辑:
我被要求检查ansible.cfg
文件。但我无法在 mac 上找到此文件。
以下是我使用ansible --version
命令时的日志
可靠的 2.7.6
config file = None
配置的模块搜索路径 = [u'/Users/dhiraj/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python 模块位置 = /Library/Python/2.7/site-packages /ansible 可执行位置 = /usr/local/bin/ansible python 版本 = 2.7.10(默认,2017 年 7 月 15 日,17:16:57)[GCC 4.2.1 兼容 Apple LLVM 9.0.0 (clang-900.0.31) ]