Suggestion for handling a service without init/systemd/upstart ?

I have to manage some systems without root access, and our services are handled with init-style scripts with status/stop/start and so forth, but not managed with any of the common process management systems.

I would like to have Ansible manage these, but the service module currently does not accomodate such a situation. I can’t do anything about ensuring these processes run at boot, but being able to stop/start, ensure running/stopped in some manner would be nice.

I was considering using register variables in the following manner as a bit of a workaround.

- name: ensure service running
  hosts: all

  tasks:

      - action: script /my/script status
        register: service_status

      - action: script /my/script start
        only_if: "'${service_status.stdout}'.find('stopped') = -1"

Better ideas? I’d like to contribute and maybe modify the service module to acommodate scripts/binaries, but my skills are limited in this area.

I'm not sure we'd want to modify the service module to support
improper services, but I think you could make something like the
service module called 'bad_service' that did similar.

I would recommend "when_string" and "in", BTW:

when_string: 'stopped' in ${service_status.stdout}

a bit cleaner!

--Michael

Hi there,

From where did you get solr?

I am currently using the example jetty instance that comes with solr 3.x

And I got the init script[1] that is recommended in solr-jetty docs[2]

[1]: http://svn.codehaus.org/jetty/jetty/branches/jetty-6.1/bin/jetty.sh
[2]: http://wiki.apache.org/solr/SolrJetty#Init_script_to_run_the_Solr_example

Ok, this seems to just be an upstream issue then.

If you install SOLR from a distribution the init scripts should pass
distribution review processes and be good to go.

The command module is really ok, I woudn't worry too much about it
executing start if it's already started because the init script should
be handling the idempotency for you.