The variable can be defined however you wish -- I'm not quite sure why you 
think it can only be passed from the command line?

On the other hand, if all you want to do is to start a service from the 
command line, you can invoke the service module via the ansible command 
itself:

ansible -m service -e 'name=foo state=started'

without having to create a playbook to do it.

On Sunday, 1 May 2016 21:49:44 UTC+1, Rick O'Shea wrote:
>
> We have host groups whose service states we wish to automate.  
>
> - name manage service
>   service: name=foo state={{state}}
>
> 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?
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7bfb4b50-9e25-4823-8e4b-f65cf604b5be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to