Closed dannystaple closed 10 months ago
Warning, it looks like something gets cached in pyinfra here when i just update env files:
pyinfra inventory.py deploy/install_base.py
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
[orionrob-disaster.local] Could not resolve hostname (orionrob-disaster.local)
--> pyinfra error: No hosts remaining!
It is supposed to be targeting the big-ole-yellow robot now.
Let's start with getting deploy/install_base.py to run.
I have modified my local .env file, thinking this would be enough to get pyinfra to deploy out, with the inventory being dynamic:
robots = [
(settings.pi_hostname, {
"ssh_user": settings.pi_username,
"board_name": settings.board_name
})
]
However, it's still trying to reach the other Pi. Can I add multiple hosts here, and filter?
Ah the --limit command is what I'll need I think:. Try pyinfra inventory.py --limit <the robot I want to update> <the operation/deployment>
$ pyinfra inventory.py --limit big-ole-yellow.local deploy/install_base.py
--> Loading config...
--> Loading inventory...
No host matches found for --limit pattern: big-ole-yellow.local
--> Connecting to hosts...
--> Preparing Operations...
Loading: deploy/install_base.py
--> Proposed changes:
--> Beginning operation run...
--> Results:
Hmm -
echo $PI_HOSTNAME
orionrob-disaster.local
Why have I got that in my environment? VScode restoring it I suppose? I was hoping my settings would let the .env file take precedence.
Ok - the limit might not have been needed- trying without the accidental settings in my environment.
Yup - that is all it was. Closing. no PR required. Just learning.
We have the test orionrob-disaster.local target but also the real world big-ole-yellow.local. The same pyinfra scripts should be able to run across both.
Ensure simply that I can run against either target. Hint: May have to rethink pyinfra using the .env files, it may all (other than secrets) need to come from inventory, with the .env file being used by the code on the robot only.
Definition of done