1

我正在尝试开始使用ansible。当我尝试使用 ansible 运行临时命令时,例如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
4

1 回答 1

1

这似乎不是 Ansible 问题,而是Trendy Corp 名为 SD Card Formatter的软件的权限问题。我不知道为什么当你运行 Ansible 时会触发它。

您的库中所有文件的权限应通过磁盘工具工具中的“修复权限”来修复。或者确保文件和文件夹/Users/Joe/library/Saved Application State/jp.co.trendy.sdformatter.savedState属于用户Joechown -R Joe:Joe /Users/Joe/library/Saved Application State/jp.co.trendy.sdformatter.savedState。如果您不关心此应用程序,则完全删除提到的文件夹也应该这样做。

于 2015-09-10T05:21:07.377 回答