ansible - 错误!在主处理程序列表和监听处理程序列表中都找不到请求的处理程序 'restart nginx'

标签 ansible

我有一个简单的角色,只安装带有重启处理程序的 nginx,但这不起作用。我收到错误消息:“错误!在主处理程序列表和监听处理程序列表中都找不到请求的处理程序‘重启 nginx’”

我做错了什么?

目录

test_handler
  handers 
    - main.yml
  tasks 
    - main.yml

处理程序/main.yml

---
# handlers file for /ansible/roles/test_handler
- name: reload nginx
  service: name=nginx state=reloaded enabled=yes
  become: yes
  become_user: root

- name: restart nginx
  service: name=nginx state=restarted enabled=yes
  become: yes
  become_user: root

任务/main.yml

- name: Install nginx
  yum: name=nginx state=latest update_cache=yes
  notify:
    - restart nginx
  become: yes
  become_user: root

最佳答案

是的,正确的@user3511320,特别是如果任务正在调用依赖于角色的任务/处理程序。 而不是包括任务用户“角色”并调用整个角色。

Use:

    roles:
    - ../roles/foo

instead of:
 tasks:
  - include_tasks: ../../roles/foo/tasks/test.yml

关于ansible - 错误!在主处理程序列表和监听处理程序列表中都找不到请求的处理程序 'restart nginx',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63374534/

相关文章:

python - 如何使用定界符在 Ansible 中拆分值

serialization - 如何在远程主机上执行 ansible 序列化命令?

ansible - 在特定主机组上运行 ansible

Ansible 和 "sudo su - "

vagrant - Ansible 在第一次运行时总是失败

loops - 在 block 模块上为 Ansible 中的一组任务发出循环

loops - 如何在 Ansible 中获取子组列表?

ANSIBLE : Access "deep" variables in YAML inventory

ansible - 如何将循环内的字典值更新为字典列表

amazon-web-services - 在 Ansible 中创建将实例启动到 Amazon VPC 的自动缩放组时在 AWS 上分配公共(public) IP 地址