0

I would like to display a debug message in my playbook.

This is my playbook:

[blablabla]
- debug:
    msg:
    - "######################################################################"
    - "                    DIAGNOSTIC AGENT INSTALLATION                     "
    - "######################################################################"
[blablabla]

When I run this playbook on multiple target , the debug message on console output is displayed as many times as hosts count (as intended).

TASK [sifac-sap-diagnosticagent : debug] *******
task path: /etc/ansible/xxxxxx/tasks/main.yml:158
ok: [server1] => {
    "msg": [
        "######################################################################",
        "                    DIAGNOSTIC AGENT INSTALLATION                     ",
        "######################################################################"
    ]
}
ok: [server2] => {
    "msg": [
        "######################################################################",
        "                    DIAGNOSTIC AGENT INSTALLATION                     ",
        "######################################################################"
    ]
}
ok: [server3] => {
    "msg": [
        "######################################################################",
        "                    DIAGNOSTIC AGENT INSTALLATION                     ",
        "######################################################################"
    ]
}
ok: [server4] => {
    "msg": [
        "######################################################################",
        "                    DIAGNOSTIC AGENT INSTALLATION                     ",
        "######################################################################"
    ]
}

I would like to display this message only once, no matter hosts count. This in order to not overload my output.

Should I use option bypass_host_loop from debug ansible module ? Another method ?

enter image description here

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html

0

1 Answer 1

2

Use the run_once keyword on the task. It will run the task only for the first available host.

Look also for run_once in the playbook keywords.

[blablabla]
- debug:
  msg:
    - "######################################################################"
    - "                    DIAGNOSTIC AGENT INSTALLATION                     "
    - "######################################################################"
  run_once: true
[blablabla]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.