Closed romanchyla closed 9 months ago
Hi @romanchyla! So currently the best way to achieve this kind of thing is using nested operations: https://docs.pyinfra.com/en/2.x/using-operations.html#nested-operations
These get executed immediately and so allow for the flow of operations you need. If a fact has already been cached you can explicitly force it to be re-collected using host.reload_fact(...)
.
Describe the bug
Pyinfra gives impression that the flow is synchronous; but behind the scenes
operations
will be executed after fact_gathering - even if the underlying facts are created by the operation. What is the recommended way to deal with the following scenario?To Reproduce
To illustrate, this is the deployment
Expected behavior
Initially, when writing it I was expecting the
files.download
andserver.shell
to happen beforehost.get_fact
-- I'm reading it top down, linearlyPyinfra will however register server shell operations first, but facts (
host.get_fact(ListDirectories)
) will be called before the operations - which will fail because the folder doesn't exist yet.What is the right way/pattern to structure such operations? I would like the fact gathering to happen (sometimes) after the operations
Meta
pyinfra --support
.-vv
and--debug
.