How to run only one task in ansible playbook?

前端 未结 7 1136
一向
一向 2020-12-22 16:10

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 jo

7条回答
  •  长情又很酷
    2020-12-22 16:13

    See my answer here: Run only one task and handler from ansible playbook

    It is possible to run separate role (from roles/ dir):

    ansible -i stage.yml -m include_role -a name=create-os-user localhost
    

    and separate task file:

    ansible -i stage.yml -m include_tasks -a file=tasks/create-os-user.yml localhost
    

    If you externalize tasks from role to root tasks/ directory (reuse is achieved by import_tasks: ../../../tasks/create-os-user.yml) you can run it independently from playbook/role.

提交回复
热议问题