Why does my Ansible task hang?
<p>I have the following ansible playbook:</p>

<pre><code>- hosts: node1
  sudo: yes
  gather_facts: no

  tasks:
  - name: update apt
    apt: update_cache=yes
  - name: install python-setuptools
    apt: name=python-setuptools update_cache=yes
  - name: easy_install pexpect module
    easy_install: name=pexpect state=latest
  - name: add geonode repo
    apt_repository: repo='ppa:geonode/stable' state=present
  - name: update apt
    apt: update_cache=yes
  - name: install geonode
    apt: name=geonode update_cache=yes
  - expect:
        command: geonode createsuperuser
        responses:
          (?i)username: 'test'
          (?i)email: 'test@test.com'
</code></pre>

<p>When I run it I get:</p>

<pre><code>PLAY [node1] *******************************************************************

TASK [update apt] **************************************************************
ok: [node1]

TASK [install python-setuptools] ***********************************************
changed: [node1]

TASK [easy_install pexpect module] *********************************************
changed: [node1]

TASK [add geonode repo] ********************************************************
changed: [node1]

TASK [update apt] **************************************************************
ok: [node1]

TASK [install geonode] *********************************************************
</code></pre>

<p>Then it hangs indefinitely. 
In the remote node (node1), I checked the dir </p>

<blockquote>
  <p>/home/vagrant/.ansible/tmp/ansible-tmp-1470059145.13-122191240803512/</p>
</blockquote>

<p>run the file inside to see why my task is hanging</p>

<blockquote>
  <p>vagrant@node1:~/.ansible/tmp/ansible-tmp-1470059145.13-122191240803512$ python apt</p>
</blockquote>

<p>and get:</p>

<pre><code>{"msg": "Failed to lock apt for exclusive operation", "failed": true, "invocation": {"module_args": {"dpkg_options": "force-confdef,force-confold", "autoremove": false, "force": false, "name": "geonode", "install_recommends": null, "package": ["geonode"], "purge": false, "allow_unauthenticated": false, "state": "present", "upgrade": null, "update_cache": true, "default_release": null, "only_upgrade": false, "deb": null, "cache_valid_time": null}}}
</code></pre>

<p>Do you have any insights?</p>

<p><strong>EDIT 1:</strong></p>

<p>It is all day I'm launching this script and never got it working. As I posted this question, obviously, the script successfully executed till the end in 15 minutes. I launched it before lunch today and after 1 hour it was still hanging. Why do I get such a different behaviour? Is there a way in which I can control it?</p>