My playbook hangs during a task.

176 views
Skip to first unread message

Keith Koene

unread,
Feb 20, 2020, 12:26:35 PM2/20/20
to Ansible Project
I have written a playbook that checks for accessible hosts, then copies a script to those hosts, runs the script, copies output to file and then looks for that file and copies it back to the local machine.  I ran this playbook through a couple of linters and even ran it using the --syntax-check flag and everything checks out fine.  When I run the playbook against a small list of hosts, it hangs on the task "Copy Files".  Not sure what the problem is and am hoping a fresh set of eyes on this will point out something I missed.  I am running this on an Oracle Linux 7 server and the hosts are all Oracle Linux 7.


---
- name: check reachable hosts
  hosts: all
  gather_facts: no
  tasks:
    - command: ping -c1 {{ inventory_hostname }}
      delegate_to: localhost
      register: ping_result
      ignore_errors: yes
    - group_by: key=reachable
      when: ping_result|success

- name: Get sudoers info
  hosts: reachable
  become: true
  gather_facts: false
  tasks:

  - name: Copy files
    copy:
       src: /home/KXK1754/getsudoers.sh
       dest: /tmp/getsudoers.sh
       owner: root
       group: root
       mode: 0700

  - name: Run script
    shell: /tmp/getsudoers.sh
    ignore_errors: yes

  - name: Find results
    find:
       paths: "/tmp/"
       patterns: "sdoers.*"
       register: file_to_copy
    
  - name: Fetch results
    fetch:
      src: "{{ item.path }}"
      dest: /var/ftp/keithtest/
      with_items: "{{ file_to_copy.files }}"
      ignore_errors: yes
      flat: yes





Stefan Hornburg (Racke)

unread,
Feb 20, 2020, 2:54:16 PM2/20/20
to ansible...@googlegroups.com
On 2/20/20 6:26 PM, Keith Koene wrote:
> I have written a playbook that checks for accessible hosts, then copies a script to those hosts, runs the script, copies
> output to file and then looks for that file and copies it back to the local machine.  I ran this playbook through a
> couple of linters and even ran it using the --syntax-check flag and everything checks out fine.  When I run the playbook
> against a small list of hosts, it hangs on the task "Copy Files".  Not sure what the problem is and am hoping a fresh
> set of eyes on this will point out something I missed.  I am running this on an Oracle Linux 7 server and the hosts are
> all Oracle Linux 7.
>

First step would be to verify whether the list of hosts in reachable group is accurate (use debug to get a list of the
hosts in this group).

Second step would be to login into the host and find out what causes the hanging.

Regards
Racke
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ec5b47bd-5f38-4311-9a0b-65e90aa34f47%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ec5b47bd-5f38-4311-9a0b-65e90aa34f47%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Ansible Krazy

unread,
Feb 25, 2020, 3:44:56 AM2/25/20
to ansible...@googlegroups.com
We faced the same problem in our production. So if the node is slow//sluggish or goes unresponsive while playbook is running, Ansible will not leave the connection or in other words will keep waiting for output from the node(s). Well, in the case, playbooks seems to be hang.

Try to use async poll in the task:

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a64bc285-2bf0-0164-5f52-038d4e18e784%40linuxia.de.
Reply all
Reply to author
Forward
0 new messages