From 6f36909074af23d299d3e5f0f3387e9cf4acad7e Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 6 Jun 2016 22:28:20 -0400 Subject: [PATCH] service now passes 'started' instead of 'running' other modules don't have to implement this directly also updated docs to prefer 'started'. fixes #16145 --- docsite/rst/become.rst | 2 +- docsite/rst/playbooks_best_practices.rst | 2 +- docsite/rst/playbooks_intro.rst | 4 ++-- lib/ansible/plugins/action/service.py | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docsite/rst/become.rst b/docsite/rst/become.rst index f71e43451d4..06606a5934e 100644 --- a/docsite/rst/become.rst +++ b/docsite/rst/become.rst @@ -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:: diff --git a/docsite/rst/playbooks_best_practices.rst b/docsite/rst/playbooks_best_practices.rst index 653d7f8a196..c1f6afe847c 100644 --- a/docsite/rst/playbooks_best_practices.rst +++ b/docsite/rst/playbooks_best_practices.rst @@ -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 diff --git a/docsite/rst/playbooks_intro.rst b/docsite/rst/playbooks_intro.rst index 7a5679ed63c..1f24250d07e 100644 --- a/docsite/rst/playbooks_intro.rst +++ b/docsite/rst/playbooks_intro.rst @@ -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 @@ -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 diff --git a/lib/ansible/plugins/action/service.py b/lib/ansible/plugins/action/service.py index 8a0cfd21ea7..f3d975cb81a 100644 --- a/lib/ansible/plugins/action/service.py +++ b/lib/ansible/plugins/action/service.py @@ -55,6 +55,10 @@ class ActionModule(ActionBase): 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: