Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
ansible handler only runs once when notified from parameterized role

I have an ansible playbook for some init services that are broadly similar with a few tweaks. In the top-level playbook, I include the role twice, like

   roles:
     - {role: "my-service", service: webserver}
     - {role: "my-service", service: scheduler}

the my-service role has tasks, which write init scripts, and handlers, which (re)start the service. tasks/main.yml looks like this:

- name: setup init scripts
  template: src=../../service-common/templates/my-service.conf dest=/etc/init/my-{{ service }}.conf
  notify:
    - restart my service

and handlers/main.yml has this content:

- name: restart my services
  service: name=my-{{ service }} state=restarted

But after the playbook runs, we're left with only the webserver service running, and the scheduler is stop/waiting. How can I make the handler see these as two separate notifications to be handled?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The Ansible documentation states:

Handlers are lists of tasks, not really any different from regular tasks, that are referenced by a globally unique name.

So it doesn't make use of any parameters, variables, etc. when determining when/how to invoke a handler. Only the name is used.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!