how to get the exit status of the each task in ansible
<ol>
<li><p>I have 3 task in my ansible yml file as below.</p>

<pre><code>---

  - name: Instance provisioning
    local_action:
      module: ec2
      region: "{{ vpc_region }}"
      key_name: "{{ ec2_keypair }}"
      instance_type: "{{ instance_type }}"
      image: "{{ ec2_image}}"
      zone: "{{ public_az }}"
      volumes:
        - device_name: "{{ device }}"
          volume_type: "{{ instance_volumetype }}"
          volume_size: "{{ volume }}"
          delete_on_termination: "{{ state }}"
      instance_tags:
        Name: "{{ instance_name }}_{{ release_name }}_APACHE"
        environment: "{{ env_type }}"
      vpc_subnet_id: "{{ public_id }}"
      assign_public_ip: "{{ public_ip_assign }}"
      group_id: "{{ sg_apache }},{{ sg_internal }}"
      wait: "{{ wait_type }}"
    register: ec2

  - name: adding group to inventory file
    lineinfile:
      dest: "/etc/ansible/hosts"
      regexp: "^\\[{{ release_name }}\\]"
      line: "[{{ release_name }}]"
      state: present

  - name: adding apache ip to hosts
    lineinfile:
      dest: "/etc/ansible/hosts"
      line: "{{ item.private_ip }} name=apache dns={{ item.public_dns_name }}
    with_items: ec2.instances
</code></pre>

<p>Now i want to check the exit status of each task whether it is success or failure.</p></li>
<li><p>If any one of the task fails my other task should not execute. </p></li>
</ol>

<p>Please advice how to write an ansible playbook</p>