On 12.01.17 20:39 Kishor Ramanan wrote:
> I am in need of a ansbile play to check the status of a service in
> CENTOS 7 / RHEL
> 
> *Expected output:*
> 
> ● docker.service - Docker Application Container Engine Loaded:
> loaded (/usr/lib/systemd/system/docker.service; enabled; vendor 
> preset: disabled) Active: active (running) since Tue 2016-11-22
> 12:24:02 EST; 1 months 20 days ago Docs: https://docs.docker.com 
> Main PID: 815 (dockerd) Memory: 65.3M CGroup:
> /system.slice/docker.service ├─  815 /usr/bin/dockerd

If I understand the check_mode description right, you could do
something like this:

- service:
    name: "docker"
    state: "started"
  check_mode: yes
  register: docker_service_status

- debug: msg="Docker is running"
  when: 'docker_service_status.change == false'

https://docs.ansible.com/ansible/playbooks_checkmode.html

Johannes

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ed77eebe-654a-d3b1-7e38-44654bbef54e%40ojkastl.de.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to