im pretty sure im running in the wrong direction, ...
# general
g
im pretty sure im running in the wrong direction, again :) i try to automate a deployment with ansible-runner. so i wrote an
deployments/project_name/main.py
script and made it invokable with
python_source
. i'm able to run it with
./pants run deployments/project_name
with and without the sandboxing feature. pretty nice but ansible-runner wants to call
ansible-playbook
via subprocess. i tried to include it as a requirement in my
python_source
but without any luck. the next try was: make a fake
ansible-playbook
executable inside my
~/.local/bin folder
. result: my
deployments/project_name/main.py
is able to find and execute it. is it the right solution to globally install ansible so it's findable by my
deployments/project_name/main.py
script or is there something i could do to include it into the path to be able to rely on the automatic fetching of ansible?
e
If you used a
pex_binary
target to run this with
exexution_mode="venv"
(https://www.pantsbuild.org/docs/reference-pex_binary#codeexecution_modecode) that should work. The venv execution mode puts all dependency console scripts on the
PATH
.
g
i tried that too, but maybe i made a mistake. i will try that again 🙂
e
Well, try
./pants package
against the
pex_binary
venv mode target and then run the PEX file that creates as a second step. The
run
goal has changed a bit recently and I don't have a good grasp of what it does in which version of Pants currently.
This will help vet venv mode works 1st, then that just leaves figuring out which version of Pants has the right run goal semantics. @bitter-ability-32190 is expert on that.
g
oh, i think i figured it out: if i do not give the pex_binary a name it seems the python_source wins the
run
goal. if i give it a name the pex_binary gets executed. cool, thx a lot 🙂
b
What version of pants are you on? Things have changed to make the end result consistent
g
2.14.0rc1
b
Ok I reread the question. So first, by running using the directory name, it's actually a shorthand for the address path/to/dirname:dirname. Likewise if you omit the name= off a target, it defaults to the directory name. I recommend either running the file
main.py
or running the binary target by name.