orionrobots / piwars_2024_disasterzone

Code for Piwars 2024 robot
MIT License
2 stars 0 forks source link

Ability to deploy robot code/configuration to all the intended robots #24

Closed dannystaple closed 10 months ago

dannystaple commented 10 months ago

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

dannystaple commented 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.

dannystaple commented 10 months ago

Let's start with getting deploy/install_base.py to run.

dannystaple commented 10 months ago

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?

dannystaple commented 10 months ago

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>

dannystaple commented 10 months ago
$ 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:
dannystaple commented 10 months ago

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.

dannystaple commented 10 months ago

Ok - the limit might not have been needed- trying without the accidental settings in my environment.

dannystaple commented 10 months ago

Yup - that is all it was. Closing. no PR required. Just learning.