# Avoid use of debug module

**URL:** <https://forum.ansible.com/t/avoid-use-of-debug-module/1920>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [October 24, 2023, 4:02pm UTC](https://forum.ansible.com/t/avoid-use-of-debug-module/1920 "2023-10-24T16:02:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevinwincott](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@Kevinwincott](https://forum.ansible.com/u/Kevinwincott)\
**Post date:** [October 24, 2023, 4:02pm UTC](https://forum.ansible.com/t/avoid-use-of-debug-module/1920/1 "2023-10-24T16:02:42Z")

</div>

Is there a way to avoid the use of ansible.builtin.debug when requiring output to be displayed?

An example would be:

```auto
    - name: print ssh key
      ansible.builtin.debug:
        msg: "{{ ssh_key }}"

```

As it stands this is getting flagged in ansible-lint and steampunk spotter as a hint to not use debug in a production environment, but it would seem there is no other choice…

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [October 24, 2023, 4:35pm UTC](https://forum.ansible.com/t/avoid-use-of-debug-module/1920/2 "2023-10-24T16:35:55Z")

</div>

Not everything a linter flags is wrong. Sometimes, in cases like this, you need to shut up linters by adding ignore statements. Check out the documentation of ansible-lint and Spotter on how to do that 🙂

---

<div class="post-metadata">

**Author:** ![Kevinwincott](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@Kevinwincott](https://forum.ansible.com/u/Kevinwincott)\
**Post date:** [October 24, 2023, 4:47pm UTC](https://forum.ansible.com/t/avoid-use-of-debug-module/1920/3 "2023-10-24T16:47:51Z")

</div>

yeah thats my final option but it seems a little misleading - dont use debug in production but there are no other choices (that im aware of) for use in production

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [October 24, 2023, 5:39pm UTC](https://forum.ansible.com/t/avoid-use-of-debug-module/1920/4 "2023-10-24T17:39:41Z")

</div>

Linters are opinionated. You do not have to share their opinions.

There’s rarely a need to output specific data in production playbook runs, so these linters have chosen to flag that as something that might have been unintentional. They also provide ways to signal to them that this specific case is an intentional choice or that you don’t find this rule useful.

---

<div class="post-metadata">

**Author:** ![valkiriaaquatica](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/valkiriaaquatica/32/1308_2.png) [@valkiriaaquatica](https://forum.ansible.com/u/valkiriaaquatica)\
**Post date:** [October 24, 2023, 9:14pm UTC](https://forum.ansible.com/t/avoid-use-of-debug-module/1920/5 "2023-10-24T21:14:18Z")

</div>

Hi Kevin,

you can try maybe to log the output to a file?

- name: print ssh key → to a file  
copy:  
content: “{{ ssh\_key }}”  
dest: /tmp/your.txt

or maybe you can make the other way around, make the task to fail:

- name: print ssh key justs when it fails  
fail:  
msg: “{{ ssh\_key }}”  
when: true
