I am running a playbook that includes a role with the roles: key. When a task within the role notifies a handler within the role it throws the following error.
ERROR! The requested handler 'Build eigen' was not found in either the main handlers list nor in the listening handlers list
The role is part of a different collection than the playbook. I am installing the collection via the command ansible-galaxy collection install $PWD -U --no-cache --verbose
and have manually cleared all the caches on the host and target machines as well, I can expand on how if this is potentially where the fix is.
I did see this error happen once with another role in the same collection but it cleared after running it again with no change to the handler but I had accidentally been calling it twice from the task when I meant to call a different handler in the same role.
I did create the handlers folder and main.yml by hand since I had previously not needed them but Ive checked the spelling and file permissions on my machine compared to auto generated ones from ansible-galaxy.
Here are the files in question
ns.collection2/roles/install_ouster/tasks/main.yml
---
# tasks file for install_ouster
- name: Git parallel checkout
community.general.git_config:
name: checkout.workers
value: 4
scope: global
- name: Git parallel checkout
community.general.git_config:
name: checkout.thresholdForParallelism
value: 100
scope: global
- name: Clone eigen repository
ansible.builtin.git:
repo: "{{ eigen_repo }}"
dest: "{{ eigen_dir }}"
version: "{{ eigen_target_version }}"
depth: 1
changed_when: true
notify: Build eigen
- name: Clone the ouster_lib repository
ansible.builtin.git:
repo: "{{ ouster_lib_repo }}"
dest: "{{ ouster_lib_dir }}"
version: "{{ ouster_lib_branch }}"
accept_newhostkey: "{{ accept_newhostkey }}"
key_file: "{{ private_key_path }}"
ns.collection2/roles/install_ouster/handlers/main.yml
---
# handlers file for install_ouster
- name: Build eigen
block:
- name: Configure eigen with cmake
ansible.builtin.command:
argv:
- cmake
- -Bbuild
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX={{ install_prefix }}
- ./
chdir: '{{ eigen_dir }}'
changed_when: true
- name: Build and install eigen
become: true
ansible.builtin.command:
argv:
- cmake
- --build build
- --target install
chdir: '{{ eigen_dir }}'
changed_when: true
ns.collection1/playbooks/sub/play.yml
---
- hosts: all
vars:
ansible_python_interpreter: auto
gcc_version: 11
gather_facts: true
pre_tasks:
- name: Update apt repo and cache
tags: [always]
become: true
ansible.builtin.apt:
update_cache: true
force_apt_get: true
cache_valid_time: 3600
roles:
- role: ns.collection2.install_ouster
vars:
ouster_lib_branch: develop
tags: [install_ouster]
tasks: ....
I did abridge the play.yml to the relevant sections and substituted for the collection and namespace names. I also did a search across all the collections in the namespace and there is only one thing named 'Build eigen'.
I have checked the spelling of handlers as well as there was reference to a syntax for notifying within a role in another stack overflow post that ended up being invalid notify: install_ouster : Build eigen
I have cleared the caches of potentially outdated roles. And if it was a cache issue there are several tasks that wouldnt run that currently do as the git config steps are new.
Most issues Ive seen with this error come from when people are spelling the handler name incorrectly or are trying to use import instead of include which seems like it shouldn't apply here.