check to see if network manager is running

The following script is suppose to to check to see if Network Manager is running. The report status section is not working as I would expect:

The following script is suppose to to check to see if Network Manager is running. The report status section is not working as I would expect:


  • hosts: ‘{{ target }}’
    sudo: yes
    gather_facts: yes
    tasks:

  • name: Network Manager Running
    shell: systemctl status NetworkManager
    when: ansible_os_family == “RedHat” and ansible_distribution_major_version == “7”
    register: service_NetworkManager_status

  • name: Report status
    shell: /bin/echo {{ ansbile_hostname }} Network Manager is running
    when: service_NetworkManager_status == True

You problably want to check service_NetworkManager_status.rc == 0 here.