kriansa / ansible-bundler

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

Dependencies #10

Closed dasunsrule32 closed 3 years ago

dasunsrule32 commented 3 years ago

According to the description in the README, it says that ansible-bundler bundles everything needed into a single executable and all that is needed on the target machine that will be run on is python and the bundle.

Long story short, I bundled my playbook and attempted to run it on a machine that only has python installed and it attempts to download everything required via pip, so ansible and all the dependencies listed in requirements.txt. This seems contradictory to the documentation.

Am I doing something wrong or is that how it is designed to work? Reason I'm asking, if it has to download all the modules, then it's not as portable as I was hoping. Thank you. :)

kriansa commented 3 years ago

The behavior is as intended: at runtime, it will look for an existing ansible installation. If not found then it will install dependencies from requirements.txt into a temp directory and proceed with the playbook from there (at the end it will erase all temp files it used in the process).

The description might not state that explicitly, and I apologize if you didn't fully understand the purpose of what a bundle means -- it bundles together all ansible dependencies, such as roles from external paths or galaxy collections. However, the runtime (Python and Ansible) is expected to exist on the host at runtime, and it installs Ansible as a fallback.

English is not my first language, so If you have a better suggestion for how to make that information clearer, I'm all ears 👍

dasunsrule32 commented 3 years ago

Makes sense. That brings in another issue then. I'll have to poke a bit more at it, but it appears it's failing to install some modules needed when moving it to a box and running where the dependencies don't exist. If I can reliably reproduce it, I'll open a separate issue. Thank you for taking the time to answer it.

As far as clarification, I'd just maybe state (however you want to word it) that the dependencies for your created bundle to run on the new machine are:

Based on the current wording, it sounded like when the bundle was being created, it pulled in Ansible and all dependencies. Maybe clarify that it will pull everything in needed for Ansible and then at runtime on another machine it will pull all python related dependencies automatically using pip on the target machine? Something to that effect to add a bit of clarity.

Thanks for the nice project by the way, I think it's a neat idea and it fits some niche scenarios. For instance, I've created a playbook that some developers will use to migrate some applications in an older environment that is getting modernized, but this playbook is a stopgap for them until they are migrated. The bundle makes it nice, because they don't need to set Ansible up except execute the bundle with the env vars that we specify as arguments to migrate their jobs. I could set something more complicated up like AWX for that, but this is a small job and temporary. So to set all that up isn't worth it right now.

Anyway, thank you! :)

kriansa commented 3 years ago

@dasunsrule32 I'm glad it helped you. In fact, this tool is more suited to smaller niche cases where a full-blown automated solution isn't worth the effort. It can also replace scenarios where you have auto-scaling ec2 instances with complex cloud-init scripts -- maybe in the future I could add some instrumentation/error handling to it so that it could also be used for unassisted/headless setups.

I'll try to draft something that resembles more the idea of what it does at compile time vs at runtime, thanks for the suggestion! 🙇