SomethingOn
SomethingOn

Reputation: 10891

Ansible service module not starting supervisor with state restarted

I have an ansible handler to restart supervisor

---
- name: 'restart supervisor'
  become: true
  service:
    name: supervisor
    enabled: yes
    state: restarted

And the handler runs but the output is skipping

RUNNING HANDLER [supervisor : restart supervisor] *******************
skipping: [redacted]

The notification happens on the initial provision of the server so supervisor is NOT running when the handler fires. Is this why it isn't restarting? If I ssh into the box and manually run sudo service supervisor restart when the service isn't running, it starts up just fine.

I even tried a start supervisor handler like this and it did the same thing...skipping and supervisor never started?

---
- name: 'start supervisor'
  become: true
  service:
    name: supervisor
    enabled: yes
    state: started

I'm running v2.3.0.0-1 but was also experiencing this issue using v2.2.2.0.

Has anyone else run into this issue with supervisor? Is there an alternative approach? Am I doing something wrong?

-- UPDATE --

There was a when clause where the role was being applied, so I decided to remove that to see if it was the culprit. Skipped again...here's the output.

RUNNING HANDLER [supervisor : restart supervisor] ******************************************************************************************************************************************************
skipping: [ansible1] => {
    "changed": false, 
    "skip_reason": "Conditional result was False", 
    "skipped": true
}

It would be nice if ansible would show me what the condition was that caused it to skip because after removing the when there is NO reason in my ansible code that would cause it to skip. There must be something internal to the service module that is causing this :s

Upvotes: 1

Views: 1092

Answers (2)

Carlos
Carlos

Reputation: 2923

Is the handler part of a dependent role? (i.e: the role that defines the handler is included in your role as a dependency in meta/main.yml). Because I've seen this happening and with the same weird "skip_reason": "Conditional result was False",. Changing the way the dependent role was included from the meta/main.yml:dependencies into the playbook.yml:roles made it work.

I've also seen it working if the role that owns the handler is included as meta dependency of a role included as playbook.yml:roles.

Not sure if this is a bug or a tricky behaviour that I don't get to understand. This happened on Ansible-playbook 2.3.2.0

Upvotes: 1

Jack
Jack

Reputation: 6158

The service module does not call the service script with the restart option, but does a start and stop. Does the supervisor service script have a status option? If it cannot get the status, it may not run the restart command at all.

Upvotes: 0

Related Questions