Commit graph

96 commits

Author SHA1 Message Date
Michael DeHaan
c94ce66de7 Style fixes so "make pep8" is clean. 2013-04-10 16:37:49 -04:00
tin
7849f31e4c Additional example in service documentation. 2013-04-04 21:03:15 +02:00
tin
d7dc4594eb Changed the service module to terminate early if only changing the enabled state.
Expanded the documentation slightly.
2013-04-04 21:00:47 +02:00
mavimo
e5fe7f1afc Double quoted version_added in documentation 2013-03-30 20:44:34 +01:00
Michael DeHaan
478963768d Merge pull request #2490 from szinck/devel
Added SunOS (Solaris, illumos, etc) service management
2013-03-24 14:45:07 -07:00
Michael DeHaan
5993866df9 Merge pull request #2440 from jochu/service-chkconfig-add
attempt to add service to chkconfig when suggested
2013-03-24 14:33:17 -07:00
Shaun Zinck
590b86b41e service: fix typo 'err' in SunOS service class 2013-03-24 13:47:56 -05:00
Paul Sbarra
6bfaf86f37 service: add systemd template support 2013-03-23 23:13:51 -05:00
Paul Sbarra
4975e11699 service: fix systemd compilation error with --check 2013-03-23 23:07:18 -05:00
Shaun Zinck
e50258cdd6 Added SunOS (Solaris, illumos, etc) service management using svcadm and svcs commands 2013-03-23 16:02:54 -05:00
Stephen Fromm
17101789ba Limit scope of arguments to service_control() in service module
This fixes handling of arguments (module argument) in service_control().
It is now locally scoped such that modifications to it, in the case of a
systemd host, do not later impact subsequent calls to service_control().
See issue #2449.

Without patch:
ansible-service[6177]: Command /usr/bin/systemctl stop cups cups , daemonize True

With patch:
ansible-service[6475]: Command /usr/bin/systemctl start cups , daemonize True

I also updated the comments to reflect the case where systemd is really
being called.
2013-03-20 08:50:36 -07:00
Jeffrey Chu
b4789f13a7 attempt to add service to chkconfig when suggested 2013-03-18 01:17:41 -07:00
Jeffrey Chu
c4d075d8a5 fail when service cannot be found by chkconfig 2013-03-18 01:12:28 -07:00
Patrik Lundin
4a3622200a Dont exit in FreeBSD/NetBSD subclass in check mode
* As the FIXMEs note: only exit if enable state is going to change.
* This is already handled in service_enable_rcconf() being called by both subclasses.
2013-03-12 20:25:25 +01:00
Nikolay Panov
d3531d0d79 Fixed 'service'. Now it respect 'enabled=no' as well. 2013-03-08 12:07:54 +07:00
Stephen Fromm
e1e5451f97 Consider service stopped if rc is 1
Per LSB spec, consider service stopped if rc from 'service status' is 1.
Added comment with url to LSB spec reference.
2013-03-06 10:18:34 -08:00
Ton Kersten
4b01169584 Squashed commit of the following:
commit e057ea671395ec8847f920a63cf9524f5c8fde5f
Author: Ton Kersten <tonk@tonkersten.com>
Date:   Thu Feb 28 13:02:25 2013 +0100

    Fixed the service command not working

    On Ubuntu 1[02].04 the service name was not recognized because
    there is a SysV style init script, but not an upstart config file.

    Example: The `ntp` client.

    Also removed extra spaces at the end of the lines, while at it.
2013-02-28 13:06:50 +01:00
Daniel Hokka Zakrisson
6e0da757db Merge pull request #2213 from huberteff/devel
Work around hanging module.  Thanks to Daniel Hozac for the tip.
2013-02-27 04:30:39 -08:00
Hubert Feyrer
8c0f95c657 Work around hanging module. Thanks to Daniel Hozac for the tip. 2013-02-27 13:26:12 +01:00
Daniel Hokka Zakrisson
79930d931a Merge pull request #2187 from dhozac/argument-type-check
Add type checking for module arguments, converting as much as possible
2013-02-26 14:05:36 -08:00
Michael DeHaan
4d4dbb370f Better detection of whether a service is managed by systemd or not. 2013-02-24 11:58:05 -05:00
Michael DeHaan
b58cce4c1f Service module now knows a little more about systemd. This module is
really due for some refactoring, but telling how a service is managed is
a little fuzzy anyway.  on a systemd system typoing the service will now
give you a rather systemd specific error which is somewhat suboptimal.
2013-02-24 11:50:39 -05:00
Michael DeHaan
72eb0f046d Run chkconfig enable/disable only when needed. TODO, apply same logic to update-rc.d/systemd 2013-02-24 10:33:40 -05:00
Michael DeHaan
2488b2dfbc If running is given as the state value instead of 'started', still return the correct end state. 2013-02-23 22:28:57 -05:00
Michael DeHaan
f7f4743746 The service module made some assumptions about how a service should be managed based on what was installed on the system in terms of service
management tools, which meant upstart services on CentOS6 were not startable.  This tweak allows things like vmware-tools to be controlled
via the service module.  More testing on other distributions (particularly with systemd) is presumably needed.
2013-02-23 20:31:29 -05:00
Daniel Hokka Zakrisson
0150f18a3b Use argument type checking to convert to boolean 2013-02-23 19:59:52 +01:00
Michael DeHaan
65b826a8a8 'make pep8' is now clean 2013-02-17 19:48:02 -05:00
Michael DeHaan
813dd8380f Taught service how to use --check mode 2013-02-17 17:45:44 -05:00
Michael DeHaan
1900cc68a7 Remove debug print message 2013-02-17 15:03:30 -05:00
Michael DeHaan
99021c1abd Make note about enablement bit 2013-02-17 12:13:26 -05:00
Michael DeHaan
4f5949eead Avoid the 'state=null' coming back from the service module. 2013-02-17 12:11:53 -05:00
Blair Zajac
6d5991aa4c Simplify and correct comparisons with None. 2013-02-16 13:32:48 -05:00
Hubert Feyrer
fa16906e43 Add support for NetBSD. Tested on NetBSD 6.0/i386. 2013-02-13 22:07:31 +01:00
Michael DeHaan
b3cc152f15 service status 4 should also be stopped 2013-02-07 21:29:31 -05:00
Daniel Hokka Zakrisson
768f41c6be Actually add stdout data to stdout buffer for daemon mode 2013-02-06 16:52:04 +01:00
Brendan Taylor
67a1997274 service module 'state' parameter comments should be processed by RST 2013-01-23 16:32:39 -07:00
Daniel Hokka Zakrisson
a9e6ce97a3 Make service module daemonize for all the broken "daemons" out there 2013-01-22 20:21:08 +01:00
Michael DeHaan
97fd76991b Merge pull request #1867 from c0rner/devel
get_service_status() is now using self.service_control() to check status
2013-01-18 15:15:07 -08:00
Rune Kaagaard
50280f4fc4 Service mod.: Proper(?) handling of return code 69
This adds "69" to the return codes from the status command that should be
considered as not running. At least "django-celery" uses this return code,
maybe others::

    /venv/bin/python /code/project/manage.py celeryctl status
    echo $? # 69 when not running.

A bit of googling let me to http://tldp.org/LDP/abs/html/exitcodes.html and
on a Ubuntu Server 12.10 I get::

    ~# cat /usr/include/sysexits.h | grep 69
    #define EX_UNAVAILABLE	69	/* service unavailable */

I'm not sure if the content of sysexits.h is the same on other OS'es.
2013-01-17 10:13:05 +01:00
root
99fe051fb8 get_service_status() is now using self.service_control() to check status
Fixes a bug where init-scripts were not used
2013-01-14 12:37:55 +01:00
Stephen Fromm
e4964f42e0 Update modules to use run_command in module_common.py
This updates apt, apt_repository, command, cron, easy_install, facter,
fireball, git, group, mount, ohai, pip, service, setup, subversion,
supervisorctl, svr4pkg, user, and yum to take advantage of run_command
in module_common.py.
2013-01-13 08:37:19 -08:00
Patrik Lundin
543c5d0de2 Use shlex for rc.conf parsing.
This makes the line parsing a lot more robust (and easier to read).
Code supplied by @dhozac, thanks!

Remove re import because this is not used anywhere.
2012-11-25 13:09:54 +01:00
Patrik Lundin
672b83b54b Rework "enabled" implementation for FreeBSD.
When trying to perform enabled=yes followed by enabled=no
against FreeBSD the module would die with the following error:
TypeError: sub() takes at most 4 arguments (5 given)

The target FreeBSD client (8.2) is running python 2.6.6. It seems the
extra 'flags' argument was added to re.sub() in 2.7.

In fixing this issue I have attempted to create a general atomic method
for modifying a rc.conf file. Hopefully this will make it easier to add
other rc based platorms. The strip/split magic was inspired by the user
module.
2012-11-25 13:09:54 +01:00
Daniel Hokka Zakrisson
48ae48973d Remove references to non-existant variable rc 2012-11-25 00:23:29 +01:00
Dag Wieers
3e538da5d0 The vars stop/start were intended as strings
This is a typo that was reported on IRC, because of this people got: "NameError: global name 'stop' is not defined".
2012-11-25 00:13:53 +01:00
Patrik Lundin
1a66a9cfb1 Refactor module to use subclasses like user module.
* Basically the moving parts from the original service module arranged in
  subclasses.
* General structure and helper methods comes from the user module.
* Less forgiving to unsupported platforms: it requires a subclass per platform.
  (This makes it easier to work on one platform without having to think about.
  what other platform might be affected in unexpected ways).
* Now has basic OpenBSD support.
* Solaris support needs to be added.

Thanks to @dhozac for general advice and Linux testing.
Thanks to @bcoca for clearing up some FreeBSD questions.
2012-11-23 21:03:17 +01:00
Jan-Piet Mens
d184f72aa9 DOCUMENTATION strings 2012-11-21 18:49:30 +01:00
Dag Wieers
a2a04f3b6d Make the default an empty string
Seems a bit strange I have to set a default in two locations.
2012-11-21 16:11:20 +01:00
Michael DeHaan
6f6559670f chmod -x for all module files in source checkout 2012-11-19 13:47:40 -05:00
Dag Wieers
6fcf939c0b Allow adding additional arguments to service module
Some services allow additional arguments to be provided on the command line. This patch makes it possible.
2012-11-18 01:48:06 +01:00