Why is my Ansible task hanging?

I have the following game to listen to:

- 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 I run it, I 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 it hangs endlessly. In remote node (node1) I checked the directory

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

run the file inside to find out why my task is hanging

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

and get:

{"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}}}

Do you have any ideas?

EDIT 1:

All day I run this script and never worked. Since I posted this question, obviously the script successfully completed to the end after 15 minutes. I started it before dinner today, and after 1 hour it was still hanging. Why do I have this behavior? Is there any way to control this?

+4
2

/var/lib/apt folder.

, , apt.

, playbook , update_cache . - :

- hosts: node1
  sudo: yes
  gather_facts: no

  tasks:
    # Pause for 5 minutes to make sure vagrant does 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'        

Ansible .

+2

, , TASK [install geonode], .

geonode createsuperuser, .

, , , , expect , .

, , geonode createsuperuser , , .

- , , .

Error: That username is already taken.

echo: yes, , , , , . ignore_errors, , , expect.

, createuperuser, , , , creates: {{ path }}/superuser_exists.txt createsuperuser, , .

, , , .

- name: Create the django superuser
  expect:
    command: "{{ virtualenv_path }}/bin/python3 {{ project_path }}/{{ api_app_name }}/manage.py createsuperuser"
    creates: "{{ project_path }}/{{ api_app_name }}/superuser_exists.txt"
    responses:
      (?i)username: "{{ superuser_username }}"
      (?i)email: "{{ superuser_email }}"
      (?i)password: "{{ superuser_password }}"
      (?i)again: "{{ superuser_password }}"

- name: Create a file to indicate that the superuser was already created
  file: path="{{ project_path }}/{{ api_app_name }}/superuser_exists.txt" state=touch
0

Source: https://habr.com/ru/post/1649797/


All Articles