Skip to content

Commit

Permalink
service now passes 'started' instead of 'running'
Browse files Browse the repository at this point in the history
other modules don't have to implement this directly
also updated docs to prefer 'started'.
fixes ansible#16145
  • Loading branch information
bcoca committed Jun 7, 2016
1 parent 1b3d6df commit 6f36909
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docsite/rst/become.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For example, to manage a system service (which requires ``root`` privileges) whe
- name: Ensure the httpd service is running
service:
name: httpd
state: running
state: started
become: true

To run a command as the ``apache`` user::
Expand Down
2 changes: 1 addition & 1 deletion docsite/rst/playbooks_best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Below is an example tasks file that explains how a role works. Our common role
tags: ntp

- name: be sure ntpd is running and enabled
service: name=ntpd state=running enabled=yes
service: name=ntpd state=started enabled=yes
tags: ntp

Here is an example handlers file. As a review, handlers are only fired when certain tasks report changes, and are run at the end
Expand Down
4 changes: 2 additions & 2 deletions docsite/rst/playbooks_intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ the web servers, and then the database servers. For example::
- name: ensure postgresql is at the latest version
yum: name=postgresql state=latest
- name: ensure that postgresql is started
service: name=postgresql state=running
service: name=postgresql state=started

You can use this method to switch between the host group you're targeting,
the username logging into the remote servers, whether to sudo or not, and so
Expand Down Expand Up @@ -274,7 +274,7 @@ the service module takes ``key=value`` arguments::

tasks:
- name: make sure apache is running
service: name=httpd state=running
service: name=httpd state=started

The **command** and **shell** modules are the only modules that just take a list
of arguments and don't use the ``key=value`` form. This makes
Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/action/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def run(self, tmp=None, task_vars=None):
if 'use' in new_module_args:
del new_module_args['use']

# for backwards compatibility
if new_module_args['state'] == 'running':
new_module_args['state'] = 'started'

self._display.vvvv("Running %s" % module)
result.update(self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars))
else:
Expand Down

0 comments on commit 6f36909

Please sign in to comment.