从另一个角色调用 eddyhub.gnome_shell 角色(来自 ansible galaxy)

Calling eddyhub.gnome_shell role (from ansible galaxy) from another role

我想在 ansible 剧本中安装 gnome 扩展并发现了这个:https://galaxy.ansible.com/eddyhub/gnome_shell/ 很好!

我组织我的剧本的方式,我想从另一个任务中调用这个角色,所以我创建了一个这样的任务(这是完整的任务文件,位于(roles/common/tasks/gnome.yaml ):

dependencies:
   - { role: eddyhub.gnome_shell, gnome_extension_path: /home/nathanhuesken/.local/share/gnome-shell/extensions/, gnome_extension_owner: nathanhuesken, gnome_shell_extensions: [442] }

但是 运行 剧本,我得到这个错误:

ERROR! Unexpected Exception: global name 'AnsibleError' is not defined
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 92, in <module>
    exit_code = cli.run()
  File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 154, in run
    results = pbex.run()
  File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 73, in run
    pb = Playbook.load(playbook_path, variable_manager=self._variable_manager, loader=self._loader)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 53, in load
    pb._load_playbook_data(file_name=file_name, variable_manager=variable_manager)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 98, in _load_playbook_data
    entry_obj = Play.load(entry, variable_manager=variable_manager, loader=self._loader)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/play.py", line 115, in load
    return p.load_data(data, variable_manager=variable_manager, loader=loader)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/base.py", line 206, in load_data
    self._attributes[name] = method(name, ds[name])
  File "/usr/lib/python2.7/site-packages/ansible/playbook/play.py", line 217, in _load_roles
    roles.append(Role.load(ri, play=self))
  File "/usr/lib/python2.7/site-packages/ansible/playbook/role/__init__.py", line 116, in load
    r._load_role_data(role_include, parent_role=parent_role)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/role/__init__.py", line 169, in _load_role_data
    self._task_blocks = load_list_of_blocks(task_data, play=self._play, role=self, loader=self._loader, variable_manager=self._variable_manager)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/helpers.py", line 58, in load_list_of_blocks
    loader=loader
  File "/usr/lib/python2.7/site-packages/ansible/playbook/block.py", line 79, in load
    return b.load_data(data, variable_manager=variable_manager, loader=loader)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/base.py", line 206, in load_data
    self._attributes[name] = method(name, ds[name])
  File "/usr/lib/python2.7/site-packages/ansible/playbook/block.py", line 115, in _load_block
    use_handlers=self._use_handlers,
  File "/usr/lib/python2.7/site-packages/ansible/playbook/helpers.py", line 178, in load_list_of_tasks
    raise AnsibleError("included task files must contain a list of tasks", obj=data)
NameError: global name 'AnsibleError' is not defined

我做错了什么?

What am I doing wrong?

您正在将子句 dependencies:(不是 Ansible 模块)放入任务文件,而它属于 meta/main.yml(阅读更多关于 role dependencies)。

目前无法从 Ansible 中的任务中调用角色。