Avoid use of debug module

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

An example would be:

    - 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…

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 :slight_smile:

2 Likes

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

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.

3 Likes

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