[X] Keep pull requests small so they can be easily reviewed.
[X] Link this PR to related issues.
Changes:
Removed dynamic naming of handlers.
Allow defining 'container_name' variable using a group_var/host_var.
No need to define 'container_name' in a static way when including this role.
Since using the "service_name" variable (which by default already contains the "container_name" variable) to uniquely identify each service, no need to name the handlers too.
- name: Dummy task
debug:
msg: "Hello world!"
- name: Including the role.
include_role:
name: mhutter.docker-systemd-service
Output:
[WARNING]: Handler 'restart container {{ container_name }}' is unusable because it has no listen topics and the name could not be templated (host-specific variables are not supported in handler names). The
error: {{ name }}: 'name' is undefined. 'name' is undefined. {{ name }}: 'name' is undefined. 'name' is undefined
ERROR! The requested handler 'restart container my_container_test' was not found in either the main handlers list nor in the listening handlers list
Checklist
[X] Keep pull requests small so they can be easily reviewed.
[X] Link this PR to related issues.
Changes:
Removed dynamic naming of handlers.
Allow defining 'container_name' variable using a group_var/host_var.
No need to define 'container_name' in a static way when including this role.
Since using the "service_name" variable (which by default already contains the "container_name" variable) to uniquely identify each service, no need to name the handlers too.
See: https://github.com/ansible/ansible/issues/63822
Error scenario:
playbooks/site.yaml
group_vars/all.yaml
roles1/tasks/main.yaml
Output: