Skip to content

Commit

Permalink
Added minor changes (documentation) and indentation for readability.
Browse files Browse the repository at this point in the history
    Readme correct referencing to new docs directory its file.
    couple comments and indentations to improve readability.
    Added a dummy Ubuntu 22 and MacOS categories as an example.
  • Loading branch information
DaanSelen committed Feb 13, 2025
1 parent ab1105b commit b7b9fda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,10 @@ The tasks you want to run should be contained under the `tasks:` with two fields
The name field is for the user of meshbook, to clarify what the following command does in a summary.<br>
The command field actually gets executed on the end-point.<br>

### Granual Operating System control:
### Granual Operating System filtering:

I have made the program so it can have a basic filter with the Operating systems. If you have a mixed group, then you need to match the image below like this:

<img src="./assets/meshcentral_os.png" alt="MeshCentral Operating System Version" width="600"/><br>
<img src="./assets/meshbook_yaml_os.png" alt="MeshBook yaml example" width="600"/>

This will filter the nodes/machines in the MeshCentral group to the ones matching this. Very basic and open for feedback. This must match the full string, not case sensitive.
I have made the program so it can have a filter with the Operating systems. If you have a mixed group, please read:
[This explanation](./docs/operating_system_filtering.md)

# Example:

Expand Down
2 changes: 2 additions & 0 deletions meshbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ async def filter_targets(devices: list[dict], os_categories: dict, target_os: st

def get_os_variants(category: str, os_map: dict) -> set:
"""Extracts all OS names under a given category if it exists."""

for key, value in os_map.items():
if key == category:
if isinstance(value, dict): # Expand nested categories
Expand All @@ -124,6 +125,7 @@ def get_os_variants(category: str, os_map: dict) -> set:
allowed_os = get_os_variants(target_os, os_categories[key])
break # Stop searching once a match is found

# Filter out unreachable devices
for device in devices:
if not device["reachable"]:
continue # Skip unreachable devices.
Expand Down
3 changes: 3 additions & 0 deletions os_categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
],
"Ubuntu": [
"Ubuntu 24.04.1 LTS"
],
"Ubuntu 22": [
"Ubuntu 22.04.1 LTS"
]
},
"MacOS": {
Expand Down

0 comments on commit b7b9fda

Please sign in to comment.