Commit graph

77 commits

Author SHA1 Message Date
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
Michael DeHaan
15af4c63e5 Merge branch 'service_bsd' of git://github.com/bcoca/ansible into devel 2012-11-03 18:58:29 -04:00
Daniel Hokka Zakrisson
1ec38eb435 Fix service module for varnish initscript in EPEL
It outputs 'dead but pid file exists'.
2012-10-31 12:31:08 +01:00
Brian Coca
e18ef3d640 Now can handle rc.conf and init.d/rc.d based systems
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2012-10-30 23:34:18 -04:00
Jan-Piet Mens
d069c57974 Reformat code: examples consistently
- added terse syntax to modules.rst
 - added description of special variables to template module
2012-10-23 15:14:01 +02:00
Michael DeHaan
95f9917df5 fix mentioning of redundant aliases in module docs, remove was removed anyway 2012-10-12 18:14:09 -04:00
Tim Bielawa
7881ddd8cb Fix typo in service module docs 2012-10-08 12:46:16 -04:00
Jan-Piet Mens
c78a0a4a49 Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
Stephen Fromm
f5d39b8677 Add module documentation for git, group, service, and user 2012-09-29 23:50:25 -07:00
Stephen Fromm
3d09c6cc21 Ignore failure of stop command if start succeeds with state=restarted
In some cases (see issue #1067) with state=restarted, a failure to stop
the service (which wasn't running) would appear to the module to be a
failure to restart the service even though it successfully started the
service.  This changes the behavior of the service module to focus
on the return code of the start command.  If the rc of stop is not
0 and the rc of start does equal 0, it considers the service
successfully restarted.  It then ignores the rc, stdout, and stderr
from the unsuccessful stop command.
2012-09-25 22:51:13 -07:00
Dave Coutu
5bf8415b3d Added cases for 'dead but subsys locked' status 2012-09-21 14:55:59 -04:00
Stephen Fromm
f0da6b191a Migrate remaining modules to use get_bin_path in module_common.py
* Migraed easy_install, pip, service, setup, and user.
* Updated fail_json message in apt_repository
* Fixed easy_install to not hardcode location of virtualenv in
  /usr/local/bin/.
* Made handling of virtualenv more consistent between easy_install and
  pip.
2012-08-29 20:26:22 -07:00
Florian Diebold
8b19fc0ef9 Remove ternary operator to fix python 2.4 compatibility. 2012-08-26 00:16:58 +02:00
Florian Diebold
fa2a65588d Support systemd in the service module.
Most of it worked already, except for the enable parameter, because it
tried to use chkconfig which only sees SysV services. First look for
systemctl and use that if it exists.
2012-08-25 22:26:34 +02:00
Michael DeHaan
1330e66709 tweak service module pattern= logic so ./hacking/test-module does not give false positives 2012-08-17 20:26:22 -04:00
Stephen Fromm
32cb95e424 Add pattern option to service module
Adds ability to check service status based on pattern.  The pattern
is a simple string.  If a pattern is provided, the output of ps is
checked first.
2012-08-17 14:00:01 -07:00
Michael DeHaan
3c2eba57fd Make pep8 tests run against the library directory as well, and associated tweaks (mostly to indentation) in the library
directory.
2012-08-11 12:35:58 -04:00
Michael DeHaan
5ed21bf443 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
2012-08-06 20:07:02 -04:00
Michael DeHaan
baacde6c74 Add encoding lines to python modules such that they can take unicode options if they are fed them, since the
AnsibleModule stuff no longer base64 encodes for simplicity and speed reasons.
2012-08-02 21:29:10 -04:00
Ingo Gottwald
c09685a241 Fixed a Bug in the service module state changed recognition 2012-08-02 17:18:25 +02:00