# Need guidance on how to develop ansible playbook for ocp pod health checks

**URL:** <https://forum.ansible.com/t/need-guidance-on-how-to-develop-ansible-playbook-for-ocp-pod-health-checks/40692>\
**Category:** Get Help\
**Created:** [February 28, 2025, 4:52am UTC](https://forum.ansible.com/t/need-guidance-on-how-to-develop-ansible-playbook-for-ocp-pod-health-checks/40692 "2025-02-28T04:52:40Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![hugonz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hugonz/32/503_2.png) [@hugonz](https://forum.ansible.com/u/hugonz)\
**Post date:** [February 28, 2025, 5:21pm UTC](https://forum.ansible.com/t/need-guidance-on-how-to-develop-ansible-playbook-for-ocp-pod-health-checks/40692/4 "2025-02-28T17:21:54Z")

</div>

If you’re new to developing playbooks, take a look at this post in the same forum: [Getting Started with Ansible - Resources](https://forum.ansible.com/t/getting-started-with-ansible-resources/1926) You need to understand basics like tasks before you can write the playbook.

That being said, if there’s a module, you should try to use the module instead of having Ansible run the command. Instead of trying to run `oc get pods -n openshift`, use the module as shown below to get the same effect.

```yaml
- name: Get OpenShift Pods
  hosts: localhost
  gather_facts: no
  environment:
    K8S_AUTH_HOST: 'http://...'
    K8S_AUTH_API_KEY: <your api key>
  tasks:
    - name: Retrieve pods in OpenShift namespace
      kubernetes.core.k8s_info:
        kind: Pod
        namespace: openshift
      register: openshift_pods

    - name: Display returned info
      debug:
        msg: "{{ openshift_pods.resources }}"

```

---

_[View the full topic](https://forum.ansible.com/t/need-guidance-on-how-to-develop-ansible-playbook-for-ocp-pod-health-checks/40692)._
