---
- name: This playbook is for Testing Disk Space
  hosts: proxy
  become: yes
  become_method: sudo
  serial: 1
  any_errors_fatal: true
  ignore_errors: yes
  gather_facts: yes
  vars:
          ansible_paython_interpreter: /usr/bin/python
  tasks:


       - name: report the status code
         shell: pgrep -x httpd >/dev/null && echo "active" || echo 
"inactive"
         register: httpd_active


       - name: check_value_httpd
         debug:
                    msg: "{{ 'httpd is inactive' if 
httpd_active.stdout=='inactive' else 'service is active' }}"
         register: one

       - name: send mail
         mail:
                 host: xxx.xxx.xxx.xxx
                 port: 25
                 subject: Report for httpd status of system
                 body: Server has httpd service stoped
                 from: xxx.xxx.xxx
                 to: milan patel <milan.pa...@xyz.ca>
                 charset: us-ascii
         when: httpd_active=='inactive'


*****************************

I am trying to check weather httpd service is running or not and if its not 
running then send an email to me. 
But its just skipping during the process . can some one help to archive 
this task of mine. is their any other way to do this ? or what is the 
mistake in my code.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ebfbf7e6-4806-4a61-a207-7ac85d06086cn%40googlegroups.com.

Reply via email to