Expansion of previous commit.
This commit is contained in:
@@ -3,9 +3,6 @@ venv
|
|||||||
meshbooks
|
meshbooks
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# temporary or to prevent big commits
|
|
||||||
examples/
|
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ So to target for example a mesh/group in MeshCentral called: "Nerthus" do:
|
|||||||
---
|
---
|
||||||
name: example configuration
|
name: example configuration
|
||||||
group: "Nerthus"
|
group: "Nerthus"
|
||||||
#target_os: "Linux" # <--- according to os_categories.json
|
#target_os: "Linux" # <--- according to os_categories.json.
|
||||||
|
powershell: True # <--- this can be important for Windows clients.
|
||||||
variables:
|
variables:
|
||||||
- name: var1
|
- name: var1
|
||||||
value: "This is the first variable"
|
value: "This is the first variable"
|
||||||
@@ -107,6 +108,12 @@ 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 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>
|
The command field actually gets executed on the end-point.<br>
|
||||||
|
|
||||||
|
### Windows Client Extra-information:
|
||||||
|
|
||||||
|
If you want to launch commands at Windows machines, make sure you have your `os_categories.conf` up-to-date with the correct reported Windows versions.<br>
|
||||||
|
And then make sure to create compatible commands, see: [windows examples](./examples/windows)<br>
|
||||||
|
Related is the yaml option: `powershell: True`.
|
||||||
|
|
||||||
### Granual Operating System filtering:
|
### Granual Operating System filtering:
|
||||||
|
|
||||||
I have made the program so it can have a filter with the Operating systems. If you have a mixed group, please read:
|
I have made the program so it can have a filter with the Operating systems. If you have a mixed group, please read:
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: Ping Multiple Points
|
||||||
|
group: "Kubernetes"
|
||||||
|
#target_os: "Debian"
|
||||||
|
variables:
|
||||||
|
- name: host1
|
||||||
|
value: "1.1.1.1"
|
||||||
|
- name: host2
|
||||||
|
value: "9.9.9.9"
|
||||||
|
- name: command1
|
||||||
|
value: "ping"
|
||||||
|
- name: cmd_arguments
|
||||||
|
value: "-c 4"
|
||||||
|
tasks:
|
||||||
|
- name: Ping host1
|
||||||
|
command: "{{ command1 }} {{ host1 }} {{ cmd_arguments }}"
|
||||||
|
|
||||||
|
- name: Ping host2
|
||||||
|
command: "{{ command1 }} {{ host2 }} {{ cmd_arguments }}"
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
name: Echo some text in the terminal of the device
|
||||||
|
group: "Development"
|
||||||
|
target_os: "Linux" # <----
|
||||||
|
variables:
|
||||||
|
- name: package_manager
|
||||||
|
value: "apt"
|
||||||
|
- name: google_dns
|
||||||
|
value: "8.8.8.8"
|
||||||
|
- name: "quad9_dns"
|
||||||
|
value: "9.9.9.9"
|
||||||
|
tasks:
|
||||||
|
- name: refresh the cache
|
||||||
|
command: "{{ package_manager }} update"
|
||||||
|
|
||||||
|
- name: display available upgrades
|
||||||
|
command: "{{ package_manager }} list --upgradable"
|
||||||
|
|
||||||
|
- name: apply upgrades
|
||||||
|
command: "{{ package_manager }} upgrade -y"
|
||||||
|
|
||||||
|
- name: cleanup remaining packages
|
||||||
|
command: "{{ package_manager }} autoremove -y"
|
||||||
|
|
||||||
|
- name: run autoclean
|
||||||
|
command: "{{ package_manager }} autoclean -y"
|
||||||
|
|
||||||
|
- name: Ping Google DNS
|
||||||
|
command: "ping {{ google_dns }} -c 4"
|
||||||
|
|
||||||
|
- name: Ping Quad9 DNS
|
||||||
|
command: "ping {{ quad9_dns }} -c 4"
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
name: Refresh the apt cache
|
||||||
|
device: "<Device-Name>"
|
||||||
|
#target_os: "Linux"
|
||||||
|
variables:
|
||||||
|
- name: package_manager
|
||||||
|
value: "apt"
|
||||||
|
tasks:
|
||||||
|
- name: refresh the {{ package_manager }} cache
|
||||||
|
command: "{{ package_manager }} update"
|
||||||
|
|
||||||
|
- name: display available upgrades with {{ package_manager }}
|
||||||
|
command: "{{ package_manager }} list --upgradable"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: Refresh the apt cache
|
||||||
|
group: "Dev"
|
||||||
|
#target_os: "Linux"
|
||||||
|
variables:
|
||||||
|
- name: package_manager
|
||||||
|
value: "apt"
|
||||||
|
tasks:
|
||||||
|
- name: refresh the cache
|
||||||
|
command: "{{ package_manager }} update"
|
||||||
|
|
||||||
|
- name: display available upgrades
|
||||||
|
command: "{{ package_manager }} list --upgradable"
|
||||||
|
|
||||||
|
- name: apply upgrades
|
||||||
|
command: "{{ package_manager }} upgrade -y"
|
||||||
|
|
||||||
|
- name: cleanup remaining packages
|
||||||
|
command: "{{ package_manager }} autoremove -y"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
name: Echo a string to the terminal through the meshbook example.
|
||||||
|
group: "Development"
|
||||||
|
target_os: "Linux"
|
||||||
|
variables:
|
||||||
|
- name: file
|
||||||
|
value: "/etc/os-release"
|
||||||
|
tasks:
|
||||||
|
- name: Echo!
|
||||||
|
command: "echo $(cat {{ file }})"
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
name: Echo a string to the terminal through the meshbook example.
|
||||||
|
group: "Endpoint"
|
||||||
|
target_os: "Windows"
|
||||||
|
powershell: True
|
||||||
|
#variables:
|
||||||
|
# - name: file
|
||||||
|
# value: "/etc/os-release"
|
||||||
|
tasks:
|
||||||
|
- name: Echo!
|
||||||
|
command: "Get-ComputerInfo | Select-Object CsName, OsName, OsArchitecture, OsLastBootUpTime | Write-Output"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
name: Echo a string to the terminal through the meshbook example.
|
||||||
|
group: "Endpoint"
|
||||||
|
target_os: "Windows"
|
||||||
|
powershell: True
|
||||||
|
tasks:
|
||||||
|
- name: Get some update information
|
||||||
|
command: "Get-HotFix | Select-Object PSComputerName, HotFixID, InstalledOn"
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
name: Echo a string to the terminal through the meshbook example.
|
||||||
|
group: "Endpoint"
|
||||||
|
target_os: "Windows"
|
||||||
|
powershell: True
|
||||||
|
#variables:
|
||||||
|
# - name: file
|
||||||
|
# value: "/etc/os-release"
|
||||||
|
tasks:
|
||||||
|
- name: Echo!
|
||||||
|
command: >
|
||||||
|
$systemInfo = Get-ComputerInfo | Select-Object CsName, OsName, OsArchitecture, OsLastBootUpTime;
|
||||||
|
$systemInfo | Format-Table -AutoSize;
|
||||||
|
Write-Output "I like monkeys.";
|
||||||
|
Get-SystemLanguage | Write-Output;
|
||||||
|
Get-ComputerInfo | Format-List;
|
||||||
+9
-2
@@ -266,7 +266,10 @@ async def execute_meshbook(session: meshctrl.Session, targets: dict, meshbook: d
|
|||||||
|
|
||||||
for task in meshbook["tasks"]:
|
for task in meshbook["tasks"]:
|
||||||
console(text_color.green + str(round) + ". Running: " + task["name"])
|
console(text_color.green + str(round) + ". Running: " + task["name"])
|
||||||
response = await session.run_command(nodeids=targets, command=task["command"],ignore_output=False,timeout=900)
|
if meshbook["powershell"]:
|
||||||
|
response = await session.run_command(nodeids=targets, command=task["command"],powershell=True,ignore_output=False,timeout=900)
|
||||||
|
else:
|
||||||
|
response = await session.run_command(nodeids=targets, command=task["command"],ignore_output=False,timeout=900)
|
||||||
|
|
||||||
task_batch = []
|
task_batch = []
|
||||||
for device in response:
|
for device in response:
|
||||||
@@ -325,7 +328,11 @@ async def main():
|
|||||||
console("meshbook: " + text_color.yellow + args.meshbook)
|
console("meshbook: " + text_color.yellow + args.meshbook)
|
||||||
console("Operating System Categorisation file: " + text_color.yellow + args.oscategories)
|
console("Operating System Categorisation file: " + text_color.yellow + args.oscategories)
|
||||||
console("Configuration file: " + text_color.yellow + args.conf)
|
console("Configuration file: " + text_color.yellow + args.conf)
|
||||||
console("Target Operating System category given: " + text_color.yellow + meshbook["target_os"])
|
if "target_os" in meshbook:
|
||||||
|
console("Target Operating System category given: " + text_color.yellow + meshbook["target_os"])
|
||||||
|
else:
|
||||||
|
console("Target Operating System category given: " + text_color.yellow + "All")
|
||||||
|
|
||||||
if "device" in meshbook:
|
if "device" in meshbook:
|
||||||
console("Target device: " + text_color.yellow + str(meshbook["device"]))
|
console("Target device: " + text_color.yellow + str(meshbook["device"]))
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"Linux": {
|
"Linux": {
|
||||||
"Debian": [
|
"Debian": [
|
||||||
@@ -14,5 +15,11 @@
|
|||||||
"Sequoia": [
|
"Sequoia": [
|
||||||
"macOS 15.0.1"
|
"macOS 15.0.1"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"Windows": {
|
||||||
|
"11": [
|
||||||
|
"Microsoft Windows 11 Home - 24H2/26100",
|
||||||
|
"Microsoft Windows 11 Pro - 24H2/26100"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user