improve check for enabled/disabled modules

Change-Id: I931abc6760c7c6ce051d49a559061ea4086b2d72
Related-Prod: PROD-35792
diff --git a/ceph/mgr.sls b/ceph/mgr.sls
index c30cb7d..c754349 100644
--- a/ceph/mgr.sls
+++ b/ceph/mgr.sls
@@ -56,6 +56,7 @@
 ceph_mgr_wait_functional:
   cmd.run:
     - name: test "$(ceph mgr dump --connect-timeout 30 | jq .available)" = "true"
+    - unless: test "$(ceph mgr dump --connect-timeout 30 | jq .available)" = "true"
     - retry:
         attempts: 5
         interval: 10
@@ -96,7 +97,7 @@
 enable_ceph_dashboard:
   cmd.run:
   - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable dashboard"
-  - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | python -c 'import sys, json; print json.load(sys.stdin)[\"enabled_modules\"] | grep dashboard"
+  - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | jq .enabled_modules[] | grep dashboard"
   - require:
     - cmd: ceph_mgr_wait_functional
     - file: common_config
@@ -106,7 +107,7 @@
 disable_ceph_dashboard:
   cmd.run:
   - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module disable dashboard"
-  - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | python -c 'import sys, json; print json.load(sys.stdin)[\"disabled_modules\"] | grep dashboard"
+  - onlyif: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | jq .enabled_modules[] | grep dashboard"
   - require:
     - cmd: ceph_mgr_wait_functional
     - file: common_config
@@ -119,7 +120,7 @@
 enable_prometheus_plugin:
   cmd.run:
   - name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable prometheus"
-  - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | python -c 'import sys, json; print json.load(sys.stdin)[\"enabled_modules\"] | grep prometheus"
+  - unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | jq .enabled_modules[] | grep prometheus"
   - require:
     - cmd: ceph_mgr_wait_functional
     - file: common_config