Unable to Run Ansible Playbook on Multiple Hosts

I have a bare-bones Ansible (2.16.8) playbook that I’m trying to run for all hosts in an inventory group, but it doesn’t seem to be working correctly. It always seems to work for at least one host, sometimes two, but never for all of them. I’ve also noticed that, when I try to run it on more than one host it asks for my passphrase 1-5 times, pauses after each host until I hit enter, then shows the others as unreachable, permission denied (full output below):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
</code>
<code>Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). </code>
Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

If I replace the group name with any of the individual hosts it runs fine, but trying to run more than one causes the problem. I can also ssh into all of them with the key I’m using.

My inventory file looks something like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>dev:
hosts:
host1:
ansible_host: 1.2.3.4
host2:
ansible_host: 1.2.3.5
host3:
ansible_host: 1.2.3.6
host4:
ansible_host: 1.2.4.4
east:
hosts:
host1:
host2:
host3:
vars:
ansible_ssh_private_key_file: "/path/to/key"
ansible_user: auser
</code>
<code>dev: hosts: host1: ansible_host: 1.2.3.4 host2: ansible_host: 1.2.3.5 host3: ansible_host: 1.2.3.6 host4: ansible_host: 1.2.4.4 east: hosts: host1: host2: host3: vars: ansible_ssh_private_key_file: "/path/to/key" ansible_user: auser </code>
dev:
  hosts:
    host1:
      ansible_host: 1.2.3.4
    host2:
      ansible_host: 1.2.3.5
    host3:
      ansible_host: 1.2.3.6
    host4:
      ansible_host: 1.2.4.4
east:
  hosts:
    host1:
    host2:
    host3:
  vars:
    ansible_ssh_private_key_file: "/path/to/key"
    ansible_user: auser

and this is the playbook I’m trying to run to test with:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>---
- name: Test
hosts:
east
tasks:
- name: Ping
ansible.builtin.ping:
</code>
<code>--- - name: Test hosts: east tasks: - name: Ping ansible.builtin.ping: </code>
---
- name: Test
  hosts:
    east
  tasks:
    - name: Ping
      ansible.builtin.ping:

I suspect whatever is causing the pause between hosts may be the problem, but I don’t know where to look to see what is causing the pause. I’ve tried running with -vvv but haven’t been able to find anything that looks obviously wrong there either. It almost acts like it’s running all of the connections at the same time and they’re interfering with one another.

Just to clarify, the playbook runs on any of the hosts individually, I just can’t get it to run for more than one at a time.

Here is an example of the full output for one attempt to run the group. The ssh passphrase was entered at each prompt and enter had to be hit to continue after each response (3 extra times, once after each “fatal: [hostxx]” message and once after the “ok: [hostxx]” message):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>ansible-playbook pingtest.yml -i inventory.yml
PLAY [Test] ***************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************
Enter passphrase for key '/home/auser/.ssh/a_servers':
Enter passphrase for key '/home/auser/.ssh/a_servers':
fatal: [host1]: UNREACHABLE! => {
"changed": false,
"unreachable": true
}
MSG:
Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Enter passphrase for key '/home/auser/.ssh/a_servers':
[WARNING]: Platform linux on host host2 is using the discovered Python interpreter at /usr/bin/python3.6, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-core/2.16/reference_appendices/interpreter_discovery.html for more information.
ok: [host2]
Enter passphrase for key '/home/auser/.ssh/a_servers':
Enter passphrase for key '/home/auser/.ssh/a_servers':
fatal: [host3]: UNREACHABLE! => {
"changed": false,
"unreachable": true
}
MSG:
Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
TASK [Ping] ***************************************************************************************************************************************************************************************************************
ok: [host2]
PLAY RECAP ****************************************************************************************************************************************************************************************************************
host1 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
host2 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
host3 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
</code>
<code>ansible-playbook pingtest.yml -i inventory.yml PLAY [Test] *************************************************************************************************************************************************************************************************************** TASK [Gathering Facts] **************************************************************************************************************************************************************************************************** Enter passphrase for key '/home/auser/.ssh/a_servers': Enter passphrase for key '/home/auser/.ssh/a_servers': fatal: [host1]: UNREACHABLE! => { "changed": false, "unreachable": true } MSG: Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). Enter passphrase for key '/home/auser/.ssh/a_servers': [WARNING]: Platform linux on host host2 is using the discovered Python interpreter at /usr/bin/python3.6, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.16/reference_appendices/interpreter_discovery.html for more information. ok: [host2] Enter passphrase for key '/home/auser/.ssh/a_servers': Enter passphrase for key '/home/auser/.ssh/a_servers': fatal: [host3]: UNREACHABLE! => { "changed": false, "unreachable": true } MSG: Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). TASK [Ping] *************************************************************************************************************************************************************************************************************** ok: [host2] PLAY RECAP **************************************************************************************************************************************************************************************************************** host1 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0 host2 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 host3 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0 </code>
ansible-playbook pingtest.yml -i inventory.yml                                                                                                                                                                           
                                                                                                                                                                                                                           
PLAY [Test] ***************************************************************************************************************************************************************************************************************
                                                                                                                                                                                                                           
TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************
Enter passphrase for key '/home/auser/.ssh/a_servers':                                                                                                                                                                   
Enter passphrase for key '/home/auser/.ssh/a_servers':                                                                                                                                                                   
fatal: [host1]: UNREACHABLE! => {                                                                                                                                                                                     
    "changed": false,                                                                                                                                                                                                      
    "unreachable": true                                                                                                                                                                                                    
}                                                                                                                                                                                                                          
                                                                                                                                                                                                                           
MSG:                                                                                                                                                                                                                       
                                                                                                                                                                                                                           
Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).                                                                                               
                                                                                                                                                                                                                           
                                                                                                                                                                                                                           
Enter passphrase for key '/home/auser/.ssh/a_servers':                                                                                                                                                                   
[WARNING]: Platform linux on host host2 is using the discovered Python interpreter at /usr/bin/python3.6, but future installation of another Python interpreter could change the meaning of that path. See             
https://docs.ansible.com/ansible-core/2.16/reference_appendices/interpreter_discovery.html for more information.                                                                                                           
ok: [host2]                                                                                                                                                                                                            
                                                                                                                                                                                                                           
Enter passphrase for key '/home/auser/.ssh/a_servers':                                                                                                                                                                   
Enter passphrase for key '/home/auser/.ssh/a_servers':
fatal: [host3]: UNREACHABLE! => {                                                                                                                                                                                       
    "changed": false,                                                                                                                                                                                                      
    "unreachable": true                                                                                                                                                                                                    
}

MSG:

Failed to connect to the host via ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).


TASK [Ping] ***************************************************************************************************************************************************************************************************************
ok: [host2]

PLAY RECAP ****************************************************************************************************************************************************************************************************************
host1                 : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   
host2                 : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
host3                 : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   

When attempting to run the playbook multiple times, the successful host seems random, it isn’t always the same host that succeeds.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật