I need to run some roles from command line for testing and sometimes I have some adhoc tasks to apply. So I use ansible to run the role. For example:

$ ansible all -i,  -m include_role -a"name=myrole" -e '@role.json'

This works fine and prints out a lot of information but it does not print task -name: text. What I mean is the text which is normally printed by ansible-playbook like this:

TASK [Do this and that...]

But ansible does not print this. Without this information, sometimes it is difficult to tell where ansible is exactly. If a task fails, it is difficult to figure out which task failed...

Is there a way to run roles in adhoc fashion and also have more information about exactly which task is running?

1 Answer 1


No, the adhoc ansible script can't print that. Workaround is creating a simple playbook:


- hosts: "{{ myhost }}"

  - import_role:
      name: "{{ myrole }}"

Run with:

ansible-playbook /path/roletest.yml -e 'myrole=coolrole myhost=awesomehost' -e '@role.json'
  • This is what I came up with as workaround also but what about inventory? If host is given as variable. I need to give -i myhost, again on command line or it says provided hosts list is empty Isn't it better if -hosts: all is used with -i myhost from command line only? Then you need 1 variable.
    – yurtesen
    Apr 1, 2020 at 11:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .