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

时间:2016-08-25 11:34:26

标签: ansible ansible-role

我想在ansible playbook中安装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

我做错了什么?

1 个答案:

答案 0 :(得分:2)

  

我做错了什么?

您正在将dependencies:子句(不是Ansible模块)放入任务文件中,而它属于meta/main.yml(详情请参阅role dependencies)。

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