我正在角色内部开发一个ansible模块(即模块位于角色的library目录中)。 我想知道是否可以从模块中排队处理程序?
这是我想要做的一个例子,但没有在任务上使用notify位。
- name: build and install my application custom_module: path=/opt/web_app notify: - restart web server理想情况下,我希望将custom_module以某种方式排队到处理程序,以便使用方式如下所示:
- name: build and install my application custom_module: path=/opt/web_appI'm developing an ansible module inside a role (that is the module lives in the library directory of the role). I was wondering if it's possible to queue a handler from within a module?
Here's an example of what I'd like to do, but without using the notify bit on the task.
- name: build and install my application custom_module: path=/opt/web_app notify: - restart web serverIdeally I'd like to have the custom_module somehow queue to handler, so that the usage would look like this:
- name: build and install my application custom_module: path=/opt/web_app最满意答案
我很确定这种事情是不可能的。 模块实际上是Ansible复制到远程主机的独立应用程序,使用提供的参数执行,然后在继续下一个模块之前解释退出值和输出。 当一个模块在远程主机上运行时,它不知道在主节点上运行的Ansible进程,因此无法挂钩它。 在playbook中使用notify属性是调用处理程序的正确方法。 你为什么要尝试以其他方式做到这一点?
I'm pretty sure this sort of thing isn't possible. Modules are, in effect, standalone applications that Ansible copies to a remote host, executes with the provided parameters, then interprets the exit value & output before proceeding on to the next module. As a module runs on a remote host it has no knowledge of the Ansible process that's running on the master node, so it has no way to hook back to it. Using the notify property in your playbook is the proper way of invoking a handler. Why would you want to try to do this some other way?
是否可以从ansible模块中对处理程序进行排队?(Is it possible to queue a handler from within an ansible module?)我正在角色内部开发一个ansible模块(即模块位于角色的library目录中)。 我想知道是否可以从模块中排队处理程序?
这是我想要做的一个例子,但没有在任务上使用notify位。
- name: build and install my application custom_module: path=/opt/web_app notify: - restart web server理想情况下,我希望将custom_module以某种方式排队到处理程序,以便使用方式如下所示:
- name: build and install my application custom_module: path=/opt/web_appI'm developing an ansible module inside a role (that is the module lives in the library directory of the role). I was wondering if it's possible to queue a handler from within a module?
Here's an example of what I'd like to do, but without using the notify bit on the task.
- name: build and install my application custom_module: path=/opt/web_app notify: - restart web serverIdeally I'd like to have the custom_module somehow queue to handler, so that the usage would look like this:
- name: build and install my application custom_module: path=/opt/web_app最满意答案
我很确定这种事情是不可能的。 模块实际上是Ansible复制到远程主机的独立应用程序,使用提供的参数执行,然后在继续下一个模块之前解释退出值和输出。 当一个模块在远程主机上运行时,它不知道在主节点上运行的Ansible进程,因此无法挂钩它。 在playbook中使用notify属性是调用处理程序的正确方法。 你为什么要尝试以其他方式做到这一点?
I'm pretty sure this sort of thing isn't possible. Modules are, in effect, standalone applications that Ansible copies to a remote host, executes with the provided parameters, then interprets the exit value & output before proceeding on to the next module. As a module runs on a remote host it has no knowledge of the Ansible process that's running on the master node, so it has no way to hook back to it. Using the notify property in your playbook is the proper way of invoking a handler. Why would you want to try to do this some other way?
发布评论