kriansa / ansible-bundler

Turn Ansible playbooks into executable files
BSD 3-Clause "New" or "Revised" License
162 stars 21 forks source link

env: ‘ansible-playbook’: No such file or directory #4

Closed elleryq closed 5 years ago

elleryq commented 5 years ago

OS: Ubuntu 18.04

Steps:

  1. Clean Ubuntu 18.04 and bundle my playbook to "playbook.run"
  2. install python and python-pip: sudo apt-get install python python-pip
  3. Run playbook.run: ./playbook.run

Output:

Installing ansible...
Collecting ansible
.... # ignore installing messages...
env: ‘ansible-playbook’: No such file or directory

Try to find out why:

  1. Extract tarball attached in playbook.run to /tmp/foo
  2. Change directory to /tmp/foo, then run "./run-playbook.sh"
  3. The modules are installed successfully in "python-deps", but "python-deps/usr/bin" is not existed. "ansible-playbook" is installed in "python-deps/home/$USER/.local/bin", not "python-deps/usr/bin", that's why "No such file or directory" appeared.
  4. If I use sudo to run: "sudo -H ./run-playbook.sh", "ansible-playbook" is installed in "python-deps/usr/local/bin"
kriansa commented 5 years ago

Thanks for the detailed info. I will look at it tonight.

kriansa commented 5 years ago

@elleryq

I've fixed this issue on release v1.2.0. Could you test it?

Also, I hope you don't need it, but to help you in case you need to debug, you can run the playbook binary with --debug --keep-temp and then run the run-playbook.sh manually.

elleryq commented 5 years ago

@elleryq

I've fixed this issue on release v1.2.0. Could you test it?

Also, I hope you don't need it, but to help you in case you need to debug, you can run the playbook binary with --debug --keep-temp and then run the run-playbook.sh manually.

I had tested v1.6.0. My environment is Ubuntu 18.04.

  1. If I just run "./playbook.run", it works.
  2. If I use "sudo -H ./playbook.run", it doesn't work. The error message is "ansible-playbook: command not found"

I check PATH, it shows:

PATH=/tmp/ansible-bundle.bky8G/python-deps/usr/bin:/tmp/ansible-bundle.bky8G/python-deps/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

But 'ansible-playbook' did installed in python-deps/usr/local/bin

ls python-deps/usr/local/bin/ ansible ansible-connection ansible-doc ansible-inventory ansible-pull ansible-config ansible-console ansible-galaxy ansible-playbook ansible-vault

kriansa commented 5 years ago

Sorry I missed this.

I'm working on a fix for that. Should be out this week.

kriansa commented 5 years ago

@elleryq can you test the version 1.7.0? I tested on a Ubuntu machine and it's working fine.

elleryq commented 5 years ago

@elleryq can you test the version 1.7.0? I tested on a Ubuntu machine and it's working fine.

I had tested 1.7.0, it works now! Thanks :)