# How Can I Conditionally Run a Preflight Check?

**URL:** <https://community.replicated.com/t/how-can-i-conditionally-run-a-preflight-check/744>\
**Category:** How do I?\
**Tags:** kots, support-bundle, troubleshoot, pre-flights\
**Created:** [March 8, 2022, 7:45pm UTC](https://community.replicated.com/t/how-can-i-conditionally-run-a-preflight-check/744 "2022-03-08T19:45:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fernando\_Cremer](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/fernando_cremer/32/436_2.png) [@Fernando\_Cremer](https://community.replicated.com/u/Fernando_Cremer)\
**Post date:** [March 8, 2022, 7:45pm UTC](https://community.replicated.com/t/how-can-i-conditionally-run-a-preflight-check/744/1 "2022-03-08T19:45:20Z")

</div>

Question:

I only want to run a specific set of preflight checks when a customer is deploying my app versus when our engineers deploy it. How can I set my `analyzers` so they only run in certain situations?

Answer:

All `analyzers` and `collectors` support the [exclude](https://troubleshoot.sh/docs/analyze/#exclude) [shared property](https://troubleshoot.sh/docs/analyze/#shared-properties). You can use this field to determine when to run any analyzer.

In the example below, we use the [License Context](https://docs.replicated.com/reference/template-functions-license-context) in the `exclude` field to determine which container runtime to check for. In this case, if the License is a ‘paid/prod’ license it checks for Containerd. Otherwise, it checks for Docker.

```nohighlight

apiVersion: troubleshoot.replicated.com/v1beta1
kind: Preflight
metadata:
  name: example-preflight-checks
spec:
  analyzers:
    - containerRuntime:
        exclude: 'repl{{ eq (LicenseFieldValue "licenseType" ) "prod" }}'
        outcomes:
          - pass:
              when: "== docker"
              message: Docker container runtime was found.
          - fail:
              message: Did not find Docker container runtime.
    - containerRuntime:
        exclude: 'repl{{ not ( eq (LicenseFieldValue "licenseType" ) "prod" ) }}'
        outcomes:
          - pass:
              when: "== containerd"
              message: Containerd container runtime was found.
          - fail:
              message: Did not find Docker container runtime.

```

---

<div class="post-metadata">

**Author:** ![JulianL](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/julianl/32/498_2.png) [@JulianL](https://community.replicated.com/u/JulianL)\
**Post date:** [November 30, 2022, 8:24am UTC](https://community.replicated.com/t/how-can-i-conditionally-run-a-preflight-check/744/2 "2022-11-30T08:24:49Z")

</div>

I see some preflight checks for `containerRuntime`, `distribution`, and `nodeResources` failing when the installation has minimal RBAC rights.

 ![Screenshot 2022-11-30 at 09.23.20](https://canada1.discourse-cdn.com/flex030/uploads/replicated/original/1X/e267b361a2bed68c08326b08980a2096b58be24c.png)

How can I exclude those checks when I don’t have required permissions?  
Since the preflights actually fail with an error, this also leads to a bunch of nasty side effects, like an error message when saving config changes.
