Hello, I'm testing an Ansible playbook and kept getting this indefinite hangs on sudo apt-get install command Ubuntu machine, I'm using Ansible version 1.4.8. server and client are both Ubuntu 14.04 since currently I'm using my own IP address to test provisioning to myself on a fresh machine. The exact code, hanging part and -vvvv info are as follows:
the exact code in my tasks main.yml:
---
# To determine if java is already installed
- name: Determine if Java is already installed
shell: which java
register: oracle_java_task_installed
ignore_errors: yes
changed_when: False
# oracle_java_installed.rc == 0 : installed
# oracle_java_installed.rc == 1 : not installed
- name: Set fact oracle_java_installed
set_fact:
oracle_java_installed = {{oracle_java_task_installed.rc == 0}}
when:
oracle_java_task_installed is defined and oracle_java_task_installed.rc is $
changed_when: False
# To install httpie
- name: Install httpie package
sudo: yes
apt:
pkg: httpie
state: present
force: yes
update_cache: yes
# To install java
- name: Add Ubuntu OpenJDK repo
sudo: yes
apt_repository: repo='ppa:openjdk-r/ppa' state=present force=yesvalidate_certs=False
tags: java
the actual running result:
cui@cui-VirtualBox:~/ansible$ ansible-playbook -i nodes provision_fabric.yml
PLAY [apply configuration to controller nodes] ********************************
GATHERING FACTS ***************************************************************
ok: [192.168.102.9]
TASK: [controller | Determine if Java is already installed] *******************
failed: [192.168.102.9] => {"changed": false, "cmd": "which java ", "delta": "0:00:00.004950", "end": "2016-09-23 10:13:11.895559", "item": "", "rc": 1, "start": "2016-09-23 10:13:11.890609", "stdout_lines": []}
...ignoring
TASK: [controller | Set fact oracle_java_installed] ***************************
skipping: [192.168.102.9]
TASK: [controller | Install httpie package] ***********************************
-vvvv info for hanging part:
TASK: [controller | Set fact oracle_java_installed] ***************************
skipping: [192.168.102.9]
TASK: [controller | Install httpie package] ***********************************
<192.168.102.9> ESTABLISH CONNECTION FOR USER: cui
<192.168.102.9> REMOTE_MODULE apt pkg=httpie state=present
<192.168.102.9> EXEC ['sshpass', '-d9', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/cui/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'ConnectTimeout=10', '192.168.102.9', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1474650902.37-263973730279195 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1474650902.37-263973730279195 && echo $HOME/.ansible/tmp/ansible-tmp-1474650902.37-263973730279195'"]
<192.168.102.9> PUT /tmp/tmpnv6U73 TO /home/cui/.ansible/tmp/ansible-tmp-1474650902.37-263973730279195/apt
<192.168.102.9> EXEC ['sshpass', '-d9', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/cui/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'ConnectTimeout=10', '192.168.102.9', '/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=uuwcaknpggvmgdoeetzulrwwmgyzyyvx] password: " -u root /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-uuwcaknpggvmgdoeetzulrwwmgyzyyvx; /usr/bin/python /home/cui/.ansible/tmp/ansible-tmp-1474650902.37-263973730279195/apt; rm -rf /home/cui/.ansible/tmp/ansible-tmp-1474650902.37-263973730279195/ >/dev/null 2>&1\'"\'"\'\'']
So far since my playbook can pass gathering fact phase, also the other commands other than sudo apt-get install can work fine, I'm rooting the ssh connection problems out. I know that someone might have the same problem it's just I've tried to add async and polls, as well as rewriting playbook commands however nothing works.Since I'm desperate to fix this one as well as I'm fairly new to Ansible. Please help me to look into this matter or tell me if there's any debugging tools good for solving such problems(be explicit if possible). Thank you!