Commit graph

38 commits

Author SHA1 Message Date
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
Stephen Fromm
85f628ae26 Return extra information from service module
If _do_enable() is run and returns rc == 0, set changed=True
Add enabled and state to result if they are supplied when the module is
run.
2012-08-01 14:58:32 -07:00
Stephen Fromm
64374ed7f2 Fix service module for issue 755 and another bug
Allow use of service module with just enable parameter, per issue #755.
Also fixed two other issues:
- fixed parameter to be 'enabled' per docs, not 'enable'.
- fixed if block that checks whether to run _do_enable() to check
  whether the parameter is set, not the value of the enable value which
  may be None or False.  If enabled=no, the service would never be
  disabled.
2012-08-01 14:44:26 -07:00
Michael DeHaan
b7c8b3458b Further service module tweaks 2012-07-28 16:48:04 -04:00
Michael DeHaan
4e0ca30014 Service tweaks WIP 2012-07-28 16:39:18 -04:00
Nikhil Singh
f24c75ce58 Standardizing the module 2012-07-28 16:39:18 -04:00
John Kleint
7933c3faed Service module outputting extra data.
The service module was printing stuff to stderr, returning two
JSON dicts, not using consistent 'failed' values, had dead code
and unused variables.  Added detection for the case when service
status returns 'xxx is dead and pid file exists' and made the
code a bit easier to read.
2012-07-19 13:15:09 -04:00
Jeremy Smitherman
290cc1c006 Added additional output to service status checker 2012-07-10 16:13:39 -04:00
Ingo Gottwald
d63b3edd02 Enhanced the service state recognition in the service module:
- Added Upstart support
- Added an initial unknown state
- Prevented state changes when the current state is not recognized
- Changed the keyword recognition to a safer method
2012-06-17 15:55:26 +02:00
cocoy
ff810ffee4 Add state=reloaded 2012-05-15 17:28:49 +08:00
Michael DeHaan
e2e4c2d7ce Allow service 'enable' parameter be 'enabled', which is what I'd personally try to use. 2012-05-09 23:13:13 -04:00
Stephen Fromm
67ee30f135 Apply logging of arguments to modules (issue #122)
The ohai and facter modules use /usr/bin/logger to log the fact that
they have been invoked.  I added 'import os' to the ping module
so that it could have the same syslog statements as the other modules.
I separated the condensed:
    shlex.split(open(argfile, 'r').read())
into two separate statements similar to the other modules.
2012-05-09 15:19:20 -07:00
Seth Vidal
a94544d15c fix up service module to make it start processes that are listed to be
running and to report errors from starting them
2012-05-04 01:20:51 -04:00
Michel Blanc
cebba29fb6 Fixes _find_binaries not using globals
_find_binaries now sets the right globals
Binaries are now properly populated (reverse path/binary for loops)
2012-05-03 12:36:06 +02:00
Michel Blanc
ca8002d7c5 Adds support for Ubuntu style update-rc.d
Checks if update-rc.d (Ubuntu) or chkconfig (RHEL) should be used.
Adds basic bin path search for those binaries
Adds 'enable' and 'disable' options for 'enable' command since it's the
arguments that update-rc.d uses (this might be somewhat confusing to
have a command line with 'enable=enable', but probably mkes sense for
Ubuntu users).
Allows use of mixed case for 'list' and 'state' commands.
2012-05-03 08:34:36 +02:00
Seth Vidal
70f4956420 new service module handles enable=on/off for chkconfigging it on 2012-05-01 17:46:45 -04:00
Michael DeHaan
7c9c3b306a Fix handling of list=status such that it will actually work in absense of the state command, to
make it useful from /usr/bin/ansible and the API.  Also some minor style fixes.
2012-04-26 22:43:36 -04:00
John Kleint
c8a542dda9 Get service module working with sudo, add list=status, better error messages.
When running the service module via sudo, `$PATH` didn't contain `/sbin`,
so the service binary couldn't be found.  This just runs `/sbin/service`
directly.  Output is spewed to stderr on error.

Added `list=status` to include the output of `service <cmd> status`.
2012-04-27 13:35:24 -04:00
jkleint
808cd1b4e9 Service module crashes if args has no "=". 2012-04-26 10:48:50 -03:00
Michael DeHaan
6f55ded1c3 Be more flexible about where the service binary lives for better cross platform support. 2012-03-30 22:57:26 -04:00
Michael DeHaan
2e060c537f Added preliminary support for --sudo to ansible, playbook support and further testing pending. 2012-03-29 01:37:06 -04:00
Christopher Johnston
4183a96495 add support for running and started - both will do the same thing 2012-03-28 16:06:26 -07:00
Michael DeHaan
cace2e7239 Added the 'test-module' script, useful for testing modules without running them in Ansible. 2012-03-14 21:49:27 -04:00
Seth Vidal
903178cdd4 convert so they handle argsfiles rather than arguments 2012-03-14 18:47:13 -04:00
Michael DeHaan
1bd1552b43 Relicensing to GPLv3, all previous committers ok'd on mailing list. 2012-02-28 19:08:09 -05:00
Michael DeHaan
8f9320aa05 Rename 'ensure' to 'state' because I think it's a bit cleaner and doesn't imply
all modules take a common parameter name.  But more or less we still work idempotently
in modules.
2012-02-26 22:31:42 -05:00
Michael DeHaan
30bc528091 Have to return the return code on failure, it's a rule! 2012-02-25 21:00:51 -05:00
Michael DeHaan
93a0cf0be4 A basic service module with 'ensure' idempotence semantics. Playbook updated to use service
module vs command module for restarting.  May be some bugs and requires the service to implement 'status' -- and probably some better error handling (i.e. return JSON with "failed" element if failed).

Improvements welcome.
2012-02-25 20:27:11 -05:00