How to run only one task in ansible playbook?


Is there a way to only run one task in ansible playbook?

For example, in roles/hadoop_primary/tasks/hadoop_master.yml. I have "start hadoop job tracker services" task. Can I just run that one task?

hadoop_master.yml file:


You should use tags: as documented in

If you have a large playbook it may become useful to be able to run a specific part of the configuration without running the whole playbook.

Both plays and tasks support a “tags:” attribute for this reason.


If you wanted to just run the “configuration” and “packages” part of a very long playbook, you could do this:

On the other hand, if you want to run a playbook without certain tasks, you could do this:

You may also apply tags to roles:

And you may also tag basic include statements:

Both of these have the function of tagging every single task inside the include statement.

Leave a Reply