How to run only one task in ansible playbook?

前端 未结 7 1128
一向
一向 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:27

    are you familiar with handlers? I think it's what you are looking for. Move the restart from hadoop_master.yml to roles/hadoop_primary/handlers/main.yml:

    - name: start hadoop jobtracker services
      service: name=hadoop-0.20-mapreduce-jobtracker state=started
    

    and now call use notify in hadoop_master.yml:

    - name: Install the namenode and jobtracker packages
      apt: name={{item}} force=yes state=latest
      with_items: 
       - hadoop-0.20-mapreduce-jobtracker
       - hadoop-hdfs-namenode
       - hadoop-doc
       - hue-plugins
      notify: start hadoop jobtracker services
    

提交回复
热议问题