Commit Graph

61 Commits (7cdc5f3f36623bf98af6a92d8275d2844ab9d9e3)

Author SHA1 Message Date
Brendan Taylor 67a1997274 service module 'state' parameter comments should be processed by RST 12 years ago
Daniel Hokka Zakrisson a9e6ce97a3 Make service module daemonize for all the broken "daemons" out there 12 years ago
Michael DeHaan 97fd76991b Merge pull request #1867 from c0rner/devel
get_service_status() is now using self.service_control() to check status
12 years ago
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.
12 years ago
root 99fe051fb8 get_service_status() is now using self.service_control() to check status
Fixes a bug where init-scripts were not used
12 years ago
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.
12 years ago
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.
12 years ago
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.
12 years ago
Daniel Hokka Zakrisson 48ae48973d Remove references to non-existant variable rc 12 years ago
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".
12 years ago
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.
12 years ago
Jan-Piet Mens d184f72aa9 DOCUMENTATION strings 12 years ago
Dag Wieers a2a04f3b6d Make the default an empty string
Seems a bit strange I have to set a default in two locations.
12 years ago
Michael DeHaan 6f6559670f chmod -x for all module files in source checkout 12 years ago
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.
12 years ago
Michael DeHaan 15af4c63e5 Merge branch 'service_bsd' of git://github.com/bcoca/ansible into devel 12 years ago
Daniel Hokka Zakrisson 1ec38eb435 Fix service module for varnish initscript in EPEL
It outputs 'dead but pid file exists'.
12 years ago
Brian Coca e18ef3d640 Now can handle rc.conf and init.d/rc.d based systems
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
12 years ago
Jan-Piet Mens d069c57974 Reformat code: examples consistently
- added terse syntax to modules.rst
 - added description of special variables to template module
12 years ago
Michael DeHaan 95f9917df5 fix mentioning of redundant aliases in module docs, remove was removed anyway 12 years ago
Tim Bielawa 7881ddd8cb Fix typo in service module docs 12 years ago
Jan-Piet Mens c78a0a4a49 Jumbo DOCUMENTATION patch 12 years ago
Stephen Fromm f5d39b8677 Add module documentation for git, group, service, and user 12 years ago
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.
12 years ago
Dave Coutu 5bf8415b3d Added cases for 'dead but subsys locked' status 12 years ago
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.
12 years ago
Florian Diebold 8b19fc0ef9 Remove ternary operator to fix python 2.4 compatibility. 12 years ago
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.
12 years ago
Michael DeHaan 1330e66709 tweak service module pattern= logic so ./hacking/test-module does not give false positives 12 years ago
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.
12 years ago
Michael DeHaan 3c2eba57fd Make pep8 tests run against the library directory as well, and associated tweaks (mostly to indentation) in the library
directory.
12 years ago
Michael DeHaan 5ed21bf443 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
12 years ago
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.
12 years ago
Ingo Gottwald c09685a241 Fixed a Bug in the service module state changed recognition 12 years ago
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.
12 years ago
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.
12 years ago
Michael DeHaan b7c8b3458b Further service module tweaks 13 years ago
Michael DeHaan 4e0ca30014 Service tweaks WIP 13 years ago
Nikhil Singh f24c75ce58 Standardizing the module 13 years ago
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.
13 years ago
Jeremy Smitherman 290cc1c006 Added additional output to service status checker 13 years ago
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
13 years ago
cocoy ff810ffee4 Add state=reloaded 13 years ago
Michael DeHaan e2e4c2d7ce Allow service 'enable' parameter be 'enabled', which is what I'd personally try to use. 13 years ago
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.
13 years ago
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
13 years ago
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)
13 years ago
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.
13 years ago
Seth Vidal 70f4956420 new service module handles enable=on/off for chkconfigging it on 13 years ago
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.
13 years ago