ansible-playbook inline help

9 views
Skip to first unread message

Emmanuel Lacour

unread,
Aug 26, 2019, 10:05:03 AM8/26/19
to Ansible Project
Dear ansible users,

is it possible to have some kind of way to write a custom help inside a playbook that would be printed once (not for each host) when you issue a command like: ansible-playbook playbooks/myplay.yml --help

?

Vladimir Botka

unread,
Aug 26, 2019, 10:39:17 AM8/26/19
to Emmanuel Lacour, ansible...@googlegroups.com
No. It's not possible. Such an option "--help" will be evaluated by
"ansible-playbook".

Instead, it is possible to use tags. For example the playbook below will
print the help and stop the play "ansible-playbook myplay.yml -t help"

- hosts: all
vars:
help_only: false
tasks:
- block:
- debug:
msg: |
This is the help for this playbook. It will be printed with
the command:
ansible-playbook myplay.yml -t help
This play will stopped now.
- set_fact:
help_only: true
run_once: true
tags: [help, never]

- meta: end_play
when: help_only

- debug:
msg: Continue play.
...

Cheers,

-vlado

Emmanuel Lacour

unread,
Aug 26, 2019, 10:43:11 AM8/26/19
to Ansible Project
 Nice, thank you very much !
Reply all
Reply to author
Forward
0 new messages