semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Listing playbook hosts failed

Open saul-jb opened this issue 4 years ago • 24 comments

I have installed and setup Semaphore on Debian 10 using Snap as per the instructions but whenever I try and run a playbook it fails with the following error:

...
Failed to add the host to the list of known hosts (/root/.ssh/known_hosts).
...
installing static inventory
No roles/requirements.yml file found. Skip galaxy install process.
Listing playbook hosts failed: fork/exec /root/snap/semaphore/common/ansible_env/bin/ansible-playbook: no such file or directory

The file /root/snap/semaphore/common/ansible_env/bin/ansible-playbook does indeed exist and is executable.

Any ideas of what the problem could be?

saul-jb avatar Sep 06 '21 02:09 saul-jb

I did a complete reinstall of the server, now I am getting:

Listing playbook hosts failed: exec: "ansible-playbook": executable file not found in $PATH

So I installed Ansible, however I still get the same problem but note:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

whereis ansible-playbook
ansible-playbook: /usr/local/bin/ansible-playbook

saul-jb avatar Sep 06 '21 04:09 saul-jb

Hm, I will try to reproduce.

fiftin avatar Sep 06 '21 11:09 fiftin

So I installed Ansible, however I still get the same problem but note

Semaphore installed via snap works in restricted mode and uses internal Ansible (/root/snap/semaphore/common/ansible_env/bin/ansible-playbook).

fiftin avatar Sep 06 '21 11:09 fiftin

Please try new version from Snap, I fixed the bug.

fiftin avatar Sep 10 '21 18:09 fiftin

I have the same issue, but when I updated the snap version and run the task again, I faced the following error:

Task # added to queue

Prepare task with template: Test 1

Updating repository <repo acess>

From <repo name>

* branch master -> FETCH_HEAD

Already up to date.

installing static inventory

No roles/requirements.yml file found. Skip galaxy install process. 

Listing playbook hosts failed: exit status 1 Traceback (most recent call last): File "/root/snap/semaphore/common/ansible_env/bin/ansible-playbook", line 63,
in <module> import ansible.constants as C File "/root/snap/semaphore/common/ansible_env/lib/python3.6/site-packages/ansible/constants.py", line 181,
in <module> config = ConfigManager() File "/root/snap/semaphore/common/ansible_env/lib/python3.6/site-packages/ansible/config/manager.py", line 307,
in __init__ self._parse_config_file() File "/root/snap/semaphore/common/ansible_env/lib/python3.6/site-packages/ansible/config/manager.py", line 336,
in _parse_config_file with open(to_bytes(cfile), 'rb') as f: PermissionError: [Errno 13] Permission denied: b'/etc/ansible/ansible.cfg' 

andavas avatar Sep 10 '21 20:09 andavas

@andavas Thank you!

I think we will got a lot of same errors, because Semaphore working in strict mode (I sure it is important) and has no access to file system.

I will fix them one by one.

fiftin avatar Sep 10 '21 21:09 fiftin

@andavas Fixed. Please update semaphore by command:

sudo snap refresh semaphore

fiftin avatar Sep 10 '21 23:09 fiftin

It works! Well, kind of... I'm having some connection issues with SSH keys, but I believe this is somehow my fault. This time the task ran (with https key) before Ansible returning the error code 4 (unreachable).

andavas avatar Sep 10 '21 23:09 andavas

@andavas thank you for test. Could you provide more details for the error?

fiftin avatar Sep 11 '21 09:09 fiftin

@fiftin This is the error that I got when I connect via HTTPS:

Task # added to queue
Preparing: #
Prepare task with template: <playbook name>
Updating repository <repo access>
From <repo link>
* branch master -> FETCH_HEAD
Already up to date.
installing static inventory
No roles/requirements.yml file found. Skip galaxy install process.

Started: #
Run task with template: <playbook name>

[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
controller starting with Ansible 2.12. Current version: 3.6.9 (default, Jan 26
2021, 15:33:00) [GCC 8.4.0]. This feature will be removed from ansible-core in
version 2.12. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.

[WARNING]: An error occurred while calling

PLAY [<task name>] *******************************************
ansible.utils.display.initialize_locale (unsupported locale setting). This may
result in incorrectly calculated text widths that can cause Display to print
incorrect line lengths

TASK [Gathering Facts] *********************************************************
fatal: [<host 1>]: UNREACHABLE! => changed=false
msg: |-
Failed to connect to the host via ssh: Failed to add the host to the list of known hosts (/root/.ssh/known_hosts).
Load key "/root/.ssh/id_rsa": Permission denied
root@<host 1>: Permission denied (publickey,password).
unreachable: true
fatal: [<host 2>]: UNREACHABLE! => changed=false
msg: |-
Failed to connect to the host via ssh: Failed to add the host to the list of known hosts (/root/.ssh/known_hosts).
Load key "/root/.ssh/id_rsa": Permission denied
root@<host 2>: Permission denied (publickey,password).
unreachable: true

PLAY RECAP *********************************************************************
<host 1> : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
<host 2> : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
Running playbook failed: exit status 4

And this is the error that I got when I connect via SSH:
(I already added the public key to github)

Task # added to queue
Preparing: #
Prepare task with template: <playbook name>
access key Chave SSH installed
Cloning repository <repo SSH link>
Cloning into 'repository_3_3'...
Failed to add the host to the list of known hosts (/root/.ssh/known_hosts).
Load key "/root/snap/semaphore/common/repositories/access_key_3": invalid format
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Failed updating repository: exit status 128

andavas avatar Sep 11 '21 20:09 andavas

@fiftin Thanks for your work in resolving this. This problem appears to be resolved but Ansible is still outputting some warnings:

SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/root/snap/semaphore/common/repositories/access_key_2"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/snap/semaphore/common/repositories/.ansible/cp/a613b48526 '[]'
[WARNING]: sftp transfer mechanism failed on []. Use ANSIBLE_DEBUG=1 to see detailed information
SSH: EXEC scp -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/root/snap/semaphore/common/repositories/access_key_2"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/snap/semaphore/common/repositories/.ansible/cp/a613b48526 /tmp/ansible-local-28967zeal879n/tmp94s5qpv8 '[]:/root/.ansible/tmp/ansible-tmp-1631499481.9691327-29114-73458269705017/AnsiballZ_command.py'
[WARNING]: scp transfer mechanism failed on []. Use ANSIBLE_DEBUG=1 to see detailed information
ESTABLISH SSH CONNECTION FOR USER: root
SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/root/snap/semaphore/common/repositories/access_key_2"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/snap/semaphore/common/repositories/.ansible/cp/a613b48526  'dd of=/root/.ansible/tmp/ansible-tmp-1631499481.9691327-29114-73458269705017/AnsiballZ_command.py bs=65536'

It still appears to work fine but it does output those warnings.

saul-jb avatar Sep 13 '21 02:09 saul-jb

The issue I have falls in the same category as the title of this issue, but it is due to the "--list-hosts" option that is appended by default on the runner. I am working with dynamic hosts coming from a group variable. This option makes it fail because I am running a playbook that imports other playbooks and hosts get added as it runs imported playbooks at the top of the list.

I am also running the latest Snap version.

pbreah avatar Oct 27 '21 21:10 pbreah

@fiftin should I create a new issue or keep the issue I'm reporting here?

pbreah avatar Oct 28 '21 14:10 pbreah

The same issue with fresh v2.8.50 and static inventory

obrazek

[all:vars]
host_domain=spoje.net
ansible_host="{{inventory_hostname}}.{{host_domain}}"

[all]
haproxy                 ansible_ssh_host=77.87.240.83 ssh_host=10.11.25.15
flexibee-dev            ansible_ssh_host=77.87.240.79
vyvojar                 ansible_ssh_host=10.11.56.151
#vyvojars               ansible_ssh_host=10.11.56.203
system                  ansible_ssh_host=10.11.56.150 ansible_python_interpreter=/usr/bin/python3 ansible_distribution_release=focal

Playbook:

---
- name: Try to ping All hosts
  hosts: all
  tasks:
  - name: Perform ping
    ping:

On debian 10

ansible 2.7.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]

How to debug ?

Vitexus avatar Feb 15 '22 19:02 Vitexus

I have exactly the same problem as @Vitexus ... I suspect this is somehow an Ansible error, but I don't know how to debug that

CorvetteCole avatar Feb 17 '22 14:02 CorvetteCole

I had the same issue. Actually it was a missing playbook that triggered that error.

l3system avatar Feb 17 '22 15:02 l3system

Actually, this playbook works fine if ran via the command line Ansible. It just fails using semaphore.

ansible-playbook -i inventory_2147483572 --step -e "ansible_user=pi ansible_ssh_pass=<password>" repository_2_7/setup-ssh-tunneling.yml

This command works perfectly in the root/snap/semaphore/common/repositories directoy... so what is the deal with semaphore?

same exact playbook, same exact inventory, same connection method (ssh with password)

CorvetteCole avatar Feb 17 '22 15:02 CorvetteCole

it even works with the bundled version of Ansible.. just not in the web ui

/root/snap/semaphore/common/ansible_env/bin/ansible-playbook -i inventory_2147483572 --step -e "ansible_user=pi ansible_ssh_pass=<password>" repository_2_7/setup-ssh-tunneling.yml

CorvetteCole avatar Feb 17 '22 15:02 CorvetteCole

i have the same issue with exit status 1 no further description.. standalone install using static or file host no difference

12:17:25 PM installing static inventory 12:17:25 PM No roles/requirements.yml file found. Skip galaxy install process. 12:17:26 PM Listing playbook hosts failed: exit status 1

Any ideas?

Driaan avatar Feb 23 '22 10:02 Driaan

@Driaan I switched to using rundeck. it has an Ansible plugin and runs great. Using your system Ansible install etc and I just love it. would recommend

CorvetteCole avatar Feb 23 '22 13:02 CorvetteCole

Upgrade to latest package fix my problem https://github.com/ansible-semaphore/semaphore/issues/718#issuecomment-1040731187

Vitexus avatar Mar 01 '22 13:03 Vitexus

Sorry for delay.

@Vitexus , problem solved?

fiftin avatar Mar 06 '22 07:03 fiftin

Sorry for delay.

@Vitexus , problem solved?

Thank you for asking :)

For me yes.

But the exact reason is still unknown.

Vitexus avatar Mar 09 '22 13:03 Vitexus

i have the same issue with exit status 1 no further description.. standalone install using static or file host no difference

12:17:25 PM installing static inventory 12:17:25 PM No roles/requirements.yml file found. Skip galaxy install process. 12:17:26 PM Listing playbook hosts failed: exit status 1

Any ideas?

did you solved it? having the exact same issue and also using no snap but "normal" installation of semaphore.. its really hard to debug as I cannot find any useful logs or output anywhere..

EDIT: found the actual reason for my issue and created a ticket at #890 as the above is really just a generic hint which can't be fixed without using the CLI to see the real error.

steadfasterX avatar Mar 15 '22 09:03 steadfasterX

我完全重新安装了服务器,现在我得到:

Listing playbook hosts failed: exec: "ansible-playbook": executable file not found in $PATH

所以我安装了 Ansible,但我仍然遇到同样的问题,但请注意:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

whereis ansible-playbook
ansible-playbook: /usr/local/bin/ansible-playbook

same problem with semaphore 2.8.74

birdmanmandbir avatar Feb 02 '23 07:02 birdmanmandbir

Just today, I installed semaphore but having this issue. Last time (few months ago), I tried. It worked that time just fine.

Running playbook failed: fork/exec /root/snap/semaphore/common/ansible_env/bin/ansible-playbook: no such file or directory

deba10106 avatar Jul 29 '23 07:07 deba10106

I'm getting a similar error:

1:26:50 AM
Started: 2147483645
1:26:50 AM
Run TaskRunner with template: ansible ping
1:26:50 AM
Preparing: 2147483645
1:26:50 AM
Cloning Repository file:///home/userxyz/templates/
1:26:50 AM
Unable to clone repository: exec: "git": executable file not found in $PATH
1:26:50 AM
Failed updating repository: exec: "git": executable file not found in $PATH
1:26:50 AM
Running playbook failed: exec: "git": executable file not found in $PATH

I am running in pve > lxc > ubuntu 22.04. Installed through snapd, nothing else done to the system apart from creating a new user and adjusting ssh options

geekscrapy avatar Sep 24 '23 21:09 geekscrapy

I am getting similar issue

3:52:19 PM Task 2147483641 added to queue 3:52:21 PM Started: 2147483641 3:52:21 PM Run TaskRunner with template: Test01 3:52:21 PM Preparing: 2147483641 3:52:21 PM Updating Repository https://github.com/reoname/ansible-basic 3:52:22 PM No collections/requirements.yml file found. Skip galaxy install process. 3:52:22 PM No roles/requirements.yml file found. Skip galaxy install process. 3:52:22 PM Running playbook failed: exec: "ansible-playbook": executable file not found in $PATH

any fix for this

sultankhan97 avatar Oct 18 '23 07:10 sultankhan97