title: run one ansible task only once during starting and run one ansible task at end
body: <p>I have below ansible playbook in which I want to do few things:</p>
  
  <ul>
  <li>I want to run first task only once in entire time this playbook will be running since I have 100 machines in <code>servers</code> group so "task one" should run only once in the starting.</li>
  <li>I want to run task three once as well but at the very end of this playbook when it is working on last machine. I am not sure if this is possible to do as well.</li>
  </ul>
  
  <p>What I need to do is:</p>
  
  <ul>
  <li>Copy <code>clients.tar.gz</code> file from some remote servers to local box (inside /tmp folder) where my ansible is running.</li>
  <li>And then unarchive this "clients.tar.gz" file on all the servers specified in "servers" group.</li>
  <li>And at the end delete this tar.gz file from /tmp folder.</li>
  </ul>
  
  <p>Below is my ansible script: Is this possible to do by any chance?</p>
  
  <pre><code>---
  - name: copy files
    hosts: servers
    serial: 10
    tasks:
        - name: copy clients.tar.gz file. Run this task only once during starting
          shell: "(scp -o StrictHostKeyChecking=no goldy@machineA:/process/snap/20180418/clients.tar.gz /tmp/) || (scp -o StrictHostKeyChecking=no goldy@machineB:/process/snap/20180418/clients.tar.gz /tmp/) || (scp -o StrictHostKeyChecking=no goldy@machineC:/process/snap/20180418/clients.tar.gz /tmp/)"
  
        - name: copy and untar latest clients.tar.gz file
          unarchive: src=/tmp/clients.tar.gz dest=/data/files/
  
        - name: Remove previous tarFile. Run this task only once at the end of this playbook
          file: path=/tmp/clients.tar.gz
                state=absent
  
        - name: sleep for few seconds
          pause: seconds=20
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>I went through the linked question and it looks like it can be done like this?</p>
  
  <pre><code>---
  - name: copy files
    hosts: servers
    serial: 10
    tasks:
        - name: copy clients.tar.gz file. Run this task only once during starting
          shell: "(scp -o StrictHostKeyChecking=no goldy@machineA:/process/snap/20180418/clients.tar.gz /tmp/) || (scp -o StrictHostKeyChecking=no goldy@machineB:/process/snap/20180418/clients.tar.gz /tmp/) || (scp -o StrictHostKeyChecking=no goldy@machineC:/process/snap/20180418/clients.tar.gz /tmp/)"
          delegate_to: "{{ groups['servers'] | first }}"
          run_once: true
  
        - name: copy and untar latest clients.tar.gz file
          unarchive: src=/tmp/clients.tar.gz dest=/data/files/
  
        - name: Remove previous tarFile. Run this task only once at the end of this playbook
          file: path=/tmp/clients.tar.gz
                state=absent
          delegate_to: "{{ groups['servers'] | last }}"
          run_once: true
  
        - name: sleep for few seconds
          pause: seconds=20
  </code></pre>