Don't show all ansible output only show msg output on the console

477 views
Skip to first unread message

Narmada Karthika

unread,
Jul 26, 2023, 1:10:10 PM7/26/23
to Ansible Project
I have a playbook with bunch of tasks,  I am running that playbook on jenkins and all my tasks are working fine. I just don't want all the output to be seen on the screen except the debug msg. Hoc can I achieve this. 

TASK [Save Repo Names to File] ************************************************* changed: [localhost] TASK [Filter Repo Names] ******************************************************* ok: [localhost] TASK [Debug Job Info] ********************************************************** ok: [localhost] => { "repos_list": [ "repo1" ] }

I just need only this

TASK [when jenkins job is created] ********************************************* ok: [localhost] => (item={'project': 'itapps', 'repo': 'repo1', 'scmUrl': 'https://github.com'}) => { "msg": "{ Job doesn't exist on any of the jenkins so Created the job on https://<jenkinsbuild.com> } \n" }

Atul Nasir

unread,
Aug 19, 2023, 2:04:43 PM8/19/23
to Ansible Project
---
- name: Your Playbook
  hosts: localhost
  tasks:
    - name: when jenkins job is created
      debug:

        msg: "{ Job doesn't exist on any of the jenkins so Created the job on https://<jenkinsbuild.com> }"
      when: your_condition_here
      register: jenkins_output

    - name: Save Repo Names to File
      # Your task definition here

    - name: Filter Repo Names
      # Your task definition here

    - name: Debug Job Info
      debug:
        var: repos_list
      when: jenkins_output|default(false)

Cody Fawcett

unread,
Aug 20, 2023, 10:28:57 AM8/20/23
to Ansible Project
you could do no_log: true

Brian Coca

unread,
Aug 21, 2023, 10:44:38 AM8/21/23
to ansible...@googlegroups.com
Or just use a custom callback that only outputs debug entries.

--
----------
Brian Coca

dulh...@mailbox.org

unread,
Aug 21, 2023, 11:18:06 AM8/21/23
to ansible...@googlegroups.com

On 21.08.23 16:44, Brian Coca wrote:
> Or just use a custom callback that only outputs debug entries.
how would that look like practically?

Brian Coca

unread,
Aug 21, 2023, 11:22:36 AM8/21/23
to ansible...@googlegroups.com
Simple example, if you just want to override task output:

def v2_runner_on_ok(self, result):
if result._task.action != 'debug':
return
....


--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages