<p>I am trying to use Ansible to put a pause in my playbook, since I am installing an operator from the Operator Hub and don't want to continue, until I know the CRDs I require in the following steps are installed. I have the following task but can't get it working yet.</p>
<pre><code>- name: Wait for CRDs to be available
  command: kubectl get sub my-operator -n openshift-operators -o json
  register: cmd
  retries: 10
  delay: 5
  until: cmd.stdout | json_query('status.conditions[0].status') == true
</code></pre>
<p>Sample JSON</p>
<pre><code>{
  &quot;apiVersion&quot;: &quot;operators.coreos.com/v1alpha1&quot;,
  &quot;kind&quot;: &quot;Subscription&quot;,
  &quot;metadata&quot;: {
    &quot;creationTimestamp&quot;: &quot;2021-12-13T04:23:58Z&quot;,
    &quot;generation&quot;: 1,
    &quot;labels&quot;: {
      &quot;operators.coreos.com/argocd-operator.openshift-operators&quot;: &quot;&quot;
    },
    &quot;name&quot;: &quot;argocd-operator&quot;,
    &quot;namespace&quot;: &quot;openshift-operators&quot;,
    &quot;resourceVersion&quot;: &quot;58122&quot;,
    &quot;uid&quot;: &quot;6eaad3c1-8329-4d00-90b8-1ab635b3b370&quot;
  },
  &quot;spec&quot;: {
    &quot;channel&quot;: &quot;alpha&quot;,
    &quot;config&quot;: {
      &quot;env&quot;: [
        {
          &quot;name&quot;: &quot;ARGOCD_CLUSTER_CONFIG_NAMESPACES&quot;,
          &quot;value&quot;: &quot;argocd&quot;
        }
      ]
    },
    &quot;installPlanApproval&quot;: &quot;Automatic&quot;,
    &quot;name&quot;: &quot;argocd-operator&quot;,
    &quot;source&quot;: &quot;community-operators&quot;,
    &quot;sourceNamespace&quot;: &quot;openshift-marketplace&quot;,
    &quot;startingCSV&quot;: &quot;argocd-operator.v0.1.0&quot;
  },
  &quot;status&quot;: {
    &quot;catalogHealth&quot;: [
      {
        &quot;catalogSourceRef&quot;: {
          &quot;apiVersion&quot;: &quot;operators.coreos.com/v1alpha1&quot;,
          &quot;kind&quot;: &quot;CatalogSource&quot;,
          &quot;name&quot;: &quot;operatorhubio-catalog&quot;,
          &quot;namespace&quot;: &quot;olm&quot;,
          &quot;resourceVersion&quot;: &quot;57924&quot;,
          &quot;uid&quot;: &quot;95871859-edbc-45ad-885c-3edaad2a1df6&quot;
        },
        &quot;healthy&quot;: true,
        &quot;lastUpdated&quot;: &quot;2021-12-13T04:23:59Z&quot;
      }
    ],
    &quot;conditions&quot;: [
      {
        &quot;lastTransitionTime&quot;: &quot;2021-12-13T04:23:59Z&quot;,
        &quot;message&quot;: &quot;targeted catalogsource openshift-marketplace/community-operators missing&quot;,
        &quot;reason&quot;: &quot;UnhealthyCatalogSourceFound&quot;,
        &quot;status&quot;: &quot;True&quot;,
        &quot;type&quot;: &quot;CatalogSourcesUnhealthy&quot;
      }
    ],
    &quot;lastUpdated&quot;: &quot;2021-12-13T04:23:59Z&quot;
  }
}
</code></pre>

CodyK
<p>There is a small detail that is tripping up the condition. In the JSON output, the status is a string <code>&quot;True&quot;</code> and not a boolean which we are comparing.</p>
<p>Note: <code>&quot;status&quot;: &quot;True&quot;</code></p>
<p>Changing the condition to match the string <code>True</code>...</p>
<pre><code>until: cmd.stdout | json_query('status.conditions[0].status') == &quot;True&quot;
</code></pre>
<p>Or, applying the <code>| bool</code> filter...</p>
<pre><code>until: stdout | json_query('status.conditions[0].status') | bool
</code></pre>
<p>The complete task:</p>
<pre class="lang-yaml prettyprint-override"><code>- name: Wait for CRDs to be available
  command: kubectl get sub my-operator -n openshift-operators -o json
  register: cmd
  retries: 10
  delay: 5
  until: cmd.stdout | json_query('status.conditions[0].status') | bool
</code></pre>
