我正在努力开始使用ansible。当我尝试使用ansible运行ad hoc命令时,例如ansible all -m ping
我必须与我的主机文件~/Development/ansible/
位于同一文件夹中或使用sudo。我已经准备好继续学习剧本,但我觉得这会在某个时候回来作为一个问题。
如果我尝试在没有sudo的情况下在该文件夹之外运行命令,我会收到此消息
<XXX.XXX.XXX.XXX> ESTABLISH CONNECTION FOR USER: Joe
<XXX.XXX.XXX.XXX> REMOTE_MODULE ping
server | FAILED => Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/ansible/runner/__init__.py", line 586, in _executor
exec_rc = self._executor_internal(host, new_stdin)
File "/Library/Python/2.7/site-packages/ansible/runner/__init__.py", line 789, in _executor_internal
return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
File "/Library/Python/2.7/site-packages/ansible/runner/__init__.py", line 1036, in _executor_internal_inner
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
File "/Library/Python/2.7/site-packages/ansible/runner/action_plugins/normal.py", line 62, in run
return self.runner._execute_module(conn, tmp, module_name, module_args, inject=inject, complex_args=complex_args)
File "/Library/Python/2.7/site-packages/ansible/runner/__init__.py", line 470, in _execute_module
) = self._configure_module(conn, module_name, args, inject, complex_args)
File "/Library/Python/2.7/site-packages/ansible/runner/__init__.py", line 1351, in _configure_module
module_path = utils.plugins.module_finder.find_plugin(module_name, module_suffixes)
File "/Library/Python/2.7/site-packages/ansible/utils/plugins.py", line 176, in find_plugin
full_paths = (os.path.join(path, f) for f in os.listdir(path))
OSError: [Errno 13] Permission denied: '/Users/Joe/library/Saved Application State/jp.co.trendy.sdformatter.savedState'
我已经做了很多搜索,但没有找到解决方案的运气。
这是我的~/.ansible.cfg
文件
# config file for ansible -- http://ansible.com/
# ==============================================
# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first
[defaults]
# some basic default values...
inventory = ~/Development/ansible/hosts
而且,这是我的主机文件
server ansible_ssh_host=XXX.XXX.XXX.XXX ansible_ssh_user=Joe ansible_ssh_private_key_file=~/.ssh/id_rsa