我有一个如下组织的剧本(为了这个问题而简化):
├── deploy.yml
├── hosts
├── requirements.yml
├── roles
│ └── web
│ ├── meta
│ │ └── main.yml
│ └── tasks
│ └── main.yml
└── site.retry
我简化的deploy.yml
是:
---
- name: Everything I need
hosts: somewhere
roles:
- web
我简化的roles/web/tasks/main.yml
是
---
- name: Various things that work
become: yes
[whatever]
- name: the thing that I have a problem with
become: yes
davidedelvento.nbextension: name=foo state=present
这失败了:
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
所以我尝试将roles/web/tasks/main.yml
更改为
---
- name: Various things that work
become: yes
[whatever]
- name: the thing that I have a problem with
become: yes
roles:
- { role: davidedelvento.nbextension, name: foo, state: present}
以同样的方式失败。我理解失败(因为我不能从一个任务中调用一个角色,而不是我正在做的 - 但错误可能会更清楚......)
然而,我不清楚我怎样才能完成我所希望的,即做任何nbextension在那个时间点所做的事情。我可以将该角色从roles/web/tasks/main.yml
移动到roles/web/meta/main.yml
并且可行,但它会在Various things that work
之前执行,我需要在之后执行。怎么做到这一点?
请注意,我写了nbextension,但同样的问题也发生在银河系的其他角色中。
编辑:请注意,扩展程序已正确安装,可以从独立的单文件手册中使用,例如
---
- name: Example
hosts: all
become: yes
roles:
- { role: davidedelvento.nbextension, name: foo, state: present}
然而,我需要它来整合"在上面针对" web"描述的大型项目中角色(我有更多的角色,我没有显示)
EDIT2:请注意,用于此问题的galaxy ansible角色已重命名为jupyterextension但正如我所说,问题(和解决方案)对于任何角色都是相同的
答案 0 :(得分:0)
好的,所以我找到了两种方法来处理这个问题。
- name: the thing that I have not a problem with anymore
become: yes
include_role:
name: davidedelvento.nbextension
with_items:
- foo
- bar
loop_control:
loop_var: name