Why does my Ansible task hang? -


i have following ansible playbook:

- 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' 

when run get:

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] ********************************************************* 

then hangs indefinitely. in remote node (node1), checked dir

/home/vagrant/.ansible/tmp/ansible-tmp-1470059145.13-122191240803512/

run file inside see why task hanging

vagrant@node1:~/.ansible/tmp/ansible-tmp-1470059145.13-122191240803512$ python apt

and get:

{"msg": "failed lock apt 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}}} 

do have insights?

edit 1:

it day i'm launching script , never got working. posted question, obviously, script executed till end in 15 minutes. launched before lunch today , after 1 hour still hanging. why such different behaviour? there way in can control it?

this issue might caused empty /var/lib/apt folder.

vagrant might take while populate these folders cause apt lock.

also playbook inefficient update_cache used multiple times. recommend use this:

- hosts: node1   sudo: yes   gather_facts: no    tasks:     # pause 5 minutes make sure vagrant not hold apt lock.     - pause:         minutes: 5      - name: add geonode repo       apt_repository:         repo: 'ppa:geonode/stable'         state: present      - name: install apt packages.       apt:         name: "{{ item }}"         state: present         update_cache: true       with_items:         - python-setuptools         - geonode    - name: create geonode superuser.     expect:       command: geonode createsuperuser       responses:         (?i)username: 'test'         (?i)email: 'test@test.com'         

this way ansible won't update repositories multiple times during play.


Comments