On 01.05.16 22:49 Rick O'Shea wrote:
> As near as we can tell this is the only way to automate a playbook to
> start, stop, restart, enable, disable or status a service is to pass a
> variable on the command line:
>
> ansible-playbook foo-service.yml -e state=started
>
> Is this best practice?
I would say putting these into the handler section of your
role/playbook would be preferable, so you only restart the service if
something has changed. Unless you want to force the restart.
Remember ansible is idempotent, so starting a service that is already
started does not harm, but does not restart it either.
Johannes