https://pantsbuild.org/ logo
#general
Title
# general
f

full-intern-53951

06/07/2021, 10:19 AM
Hi Team, is it possible to package ansible-runner and ansible playbooks using PEX
h

happy-kitchen-89482

06/07/2021, 12:00 PM
I don't see why it wouldn't be possible. In principle if you can put it in a virtualenv you can put it in a pex. But I'm curious if anyone has done this in practice yet?
p

proud-dentist-22844

06/07/2021, 2:35 PM
Be careful as ansible cannot be made into a wheel due to its use of symlinks in the code. You may hit a few speed bumps from those symlinks.
f

full-intern-53951

06/08/2021, 4:19 AM
Hi Benjyw, FYI: we were able to build the executable successfully yesterday, Thanks a lot for quick response and help
today we will testing to by porting it other nodes
🤞 1
Appreciate your help!
It is failing when we using call ansible_runner using the relative path from package ex:
Copy code
r = ansible_runner.run(private_data_dir='./ansible_runner', playbook=playbook_name, quiet=False,
                       cmdline=cmd_line, rotate_artifacts=1)
./dist/src.python.sre_playbooks/sre_play.pex Config file loded validating auth token.... Remediation starting for localhost fsused-percent : disk_space_runbook.yml Check curret path: /Users/test/projects/test/pexPackage 2/hosts disk_space_runbook.yml ERROR! the playbook: disk_space_runbook.yml could not be found
we have checked the disk_space_runbook.yml is bundled inside ansible_runner/projects/disk_space_runbook.yml and file exists
a

acoustic-computer-61887

06/08/2021, 2:52 PM
@happy-kitchen-89482 @proud-dentist-22844 I have one more question, while using ansible_runner can we use Python’s 
open()
to read a 
resources
 target? Or “open()” is only available with
files
 target?
h

hundreds-father-404

06/08/2021, 3:54 PM
You should use resources. Files are not included in the PEX Alternatively you can use archive. https://www.pantsbuild.org/docs/resources
f

full-intern-53951

06/08/2021, 5:28 PM
Hi @hundreds-father-404, We are trying package complete project with ansible-runner in single executable file but we are find issue running the playbooks as mentioned above(ERROR! the playbook: disk_space_runbook.yml could not be found). we have tried to testing https://github.com/alex-leonhardt/ansible-pex it also failed to build executable. could you please advise how to bundle ansible-runner with all other python scripts in single pex
h

happy-kitchen-89482

06/08/2021, 9:15 PM
How are you expressing the target that wraps the .yml file? It should probably be a
resources()
target.
And have you tried creating the pex with
execution_mode='unzip'
(or
'venv'
) ?