How to run only one task in ansible playbook?

前端 未结 7 1120
一向
一向 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:28

    FWIW with Ansible 2.2 one can use include_role:

    playbook test.yml:

    - name: test
      hosts:
        - 127.0.0.1
      connection: local
      tasks:
        - include_role:
            name: test
            tasks_from: other
    

    then in roles/test/tasks/other.yml:

    - name: say something else
      shell: echo "I'm the other guy"
    

    And invoke the playbook with: ansible-playbook test.yml to get:

    TASK [test : say something else] *************
    changed: [127.0.0.1]
    

提交回复
热议问题