configstash-agent 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- configstash_agent-0.1.0/LICENSE +21 -0
- configstash_agent-0.1.0/PKG-INFO +142 -0
- configstash_agent-0.1.0/README.md +112 -0
- configstash_agent-0.1.0/configstash_agent/__init__.py +1 -0
- configstash_agent-0.1.0/configstash_agent/cli.py +737 -0
- configstash_agent-0.1.0/configstash_agent/collector.py +74 -0
- configstash_agent-0.1.0/configstash_agent/config.py +66 -0
- configstash_agent-0.1.0/configstash_agent/demo.py +255 -0
- configstash_agent-0.1.0/configstash_agent/scheduler.py +62 -0
- configstash_agent-0.1.0/configstash_agent/sender.py +107 -0
- configstash_agent-0.1.0/configstash_agent.egg-info/PKG-INFO +142 -0
- configstash_agent-0.1.0/configstash_agent.egg-info/SOURCES.txt +16 -0
- configstash_agent-0.1.0/configstash_agent.egg-info/dependency_links.txt +1 -0
- configstash_agent-0.1.0/configstash_agent.egg-info/entry_points.txt +2 -0
- configstash_agent-0.1.0/configstash_agent.egg-info/requires.txt +5 -0
- configstash_agent-0.1.0/configstash_agent.egg-info/top_level.txt +1 -0
- configstash_agent-0.1.0/pyproject.toml +54 -0
- configstash_agent-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ConfigStash
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: configstash-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight agent that backs up network device configs (MikroTik, Ubiquiti) to ConfigStash
|
|
5
|
+
Author-email: ConfigStash <support@configstash.io>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://configstash.io
|
|
8
|
+
Project-URL: Source, https://github.com/configstash/configstash-agent
|
|
9
|
+
Project-URL: Issues, https://github.com/configstash/configstash-agent/issues
|
|
10
|
+
Keywords: network,backup,mikrotik,routeros,ubiquiti,edgerouter,unifi,config-backup,netmiko
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: System :: Networking
|
|
20
|
+
Classifier: Topic :: System :: Systems Administration
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: netmiko>=4.4.0
|
|
25
|
+
Requires-Dist: click>=8.1.7
|
|
26
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
27
|
+
Requires-Dist: requests>=2.32.4
|
|
28
|
+
Requires-Dist: croniter>=3.0.3
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# ConfigStash Agent
|
|
32
|
+
|
|
33
|
+
A small on-premise collector that backs up your network device configs
|
|
34
|
+
(MikroTik RouterOS, Ubiquiti EdgeRouter/EdgeSwitch/UniFi Switch) to your
|
|
35
|
+
ConfigStash server.
|
|
36
|
+
|
|
37
|
+
**Your device credentials never leave your network.** The agent connects to
|
|
38
|
+
devices over SSH locally and pushes only the resulting config text to the API
|
|
39
|
+
over outbound HTTPS, authenticated with an agent token. No inbound ports needed.
|
|
40
|
+
|
|
41
|
+
## Quick Start: from zero to first backup in 5 minutes
|
|
42
|
+
|
|
43
|
+
**Prerequisites:** Python 3.12+, a ConfigStash account, SSH access to at least one device.
|
|
44
|
+
|
|
45
|
+
### 1. Install (30 sec)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install git+https://github.com/configstash/configstash-agent.git
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Get an agent token (1 min)
|
|
52
|
+
|
|
53
|
+
In the ConfigStash web UI: **Settings → Agents → Create agent**.
|
|
54
|
+
Copy the token (`cst_agent_...`) — it is shown only once.
|
|
55
|
+
|
|
56
|
+
### 3. Initialize (30 sec)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
configstash-agent init
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Enter your API URL (e.g. `https://api.yourdomain.com`) and the agent token.
|
|
63
|
+
This creates `~/.configstash/config.yaml` (permissions `600`).
|
|
64
|
+
|
|
65
|
+
### 4. Add a device (1 min)
|
|
66
|
+
|
|
67
|
+
In the web UI: **Dashboard → Add device**. Copy the device ID it shows, then
|
|
68
|
+
add the device to `~/.configstash/config.yaml`:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
devices:
|
|
72
|
+
- name: "Office MikroTik"
|
|
73
|
+
device_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # from the web UI
|
|
74
|
+
host: 192.168.88.1
|
|
75
|
+
device_type: mikrotik_routeros # mikrotik_routeros | ubiquiti_edgerouter | ubiquiti_edgeswitch | ubiquiti_unifiswitch
|
|
76
|
+
username: admin
|
|
77
|
+
password: "your-ssh-password"
|
|
78
|
+
port: 22
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
> Tip: create a dedicated read-only SSH user on the device for backups.
|
|
82
|
+
|
|
83
|
+
### 5. Test and run (2 min)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
configstash-agent test # dry run: SSH connect + collect, nothing sent
|
|
87
|
+
configstash-agent run # collect and upload your first backup
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Open the web UI — your backup is there. Done. 🎉
|
|
91
|
+
|
|
92
|
+
### 6. Keep it running
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
configstash-agent install-service # auto-start on boot (systemd / launchd)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
By default backups run every 6 hours (`schedule: "0 */6 * * *"` — standard
|
|
99
|
+
cron syntax, edit in config.yaml) with a heartbeat every 5 minutes.
|
|
100
|
+
|
|
101
|
+
## No devices yet? Try demo mode
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
configstash-agent demo --api-url https://api.yourdomain.com --token cst_agent_... --repeat 3
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Creates a virtual MikroTik and uploads realistic configs with changes between
|
|
108
|
+
runs — great for seeing the diff viewer in action.
|
|
109
|
+
|
|
110
|
+
## All commands
|
|
111
|
+
|
|
112
|
+
| Command | What it does |
|
|
113
|
+
|---------|--------------|
|
|
114
|
+
| `init` | Interactive config creation |
|
|
115
|
+
| `test` | Dry run: SSH to all devices, don't upload |
|
|
116
|
+
| `run` | One-shot: collect and upload all devices |
|
|
117
|
+
| `start` | Foreground daemon on cron schedule (`-d` to background) |
|
|
118
|
+
| `stop` / `status` | Manage the running daemon |
|
|
119
|
+
| `install-service` / `uninstall-service` | systemd/launchd auto-start |
|
|
120
|
+
| `demo` | Fake device backups, no SSH needed |
|
|
121
|
+
| `uninstall` | Remove agent and local data (cloud backups stay) |
|
|
122
|
+
|
|
123
|
+
## Docker
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
cp config.example.yaml config.yaml # edit it
|
|
127
|
+
docker compose up -d
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
On Linux, uncomment `network_mode: host` in `docker-compose.yml` if your
|
|
131
|
+
devices aren't reachable from the container network.
|
|
132
|
+
|
|
133
|
+
## Notes
|
|
134
|
+
|
|
135
|
+
- Failed uploads are queued in `~/.configstash/pending/` and retried on the
|
|
136
|
+
next run — safe across API downtime.
|
|
137
|
+
- All local state lives in `~/.configstash/` (mode `700`).
|
|
138
|
+
- Always use an `https://` API URL in production — the agent warns otherwise.
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# ConfigStash Agent
|
|
2
|
+
|
|
3
|
+
A small on-premise collector that backs up your network device configs
|
|
4
|
+
(MikroTik RouterOS, Ubiquiti EdgeRouter/EdgeSwitch/UniFi Switch) to your
|
|
5
|
+
ConfigStash server.
|
|
6
|
+
|
|
7
|
+
**Your device credentials never leave your network.** The agent connects to
|
|
8
|
+
devices over SSH locally and pushes only the resulting config text to the API
|
|
9
|
+
over outbound HTTPS, authenticated with an agent token. No inbound ports needed.
|
|
10
|
+
|
|
11
|
+
## Quick Start: from zero to first backup in 5 minutes
|
|
12
|
+
|
|
13
|
+
**Prerequisites:** Python 3.12+, a ConfigStash account, SSH access to at least one device.
|
|
14
|
+
|
|
15
|
+
### 1. Install (30 sec)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install git+https://github.com/configstash/configstash-agent.git
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 2. Get an agent token (1 min)
|
|
22
|
+
|
|
23
|
+
In the ConfigStash web UI: **Settings → Agents → Create agent**.
|
|
24
|
+
Copy the token (`cst_agent_...`) — it is shown only once.
|
|
25
|
+
|
|
26
|
+
### 3. Initialize (30 sec)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
configstash-agent init
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Enter your API URL (e.g. `https://api.yourdomain.com`) and the agent token.
|
|
33
|
+
This creates `~/.configstash/config.yaml` (permissions `600`).
|
|
34
|
+
|
|
35
|
+
### 4. Add a device (1 min)
|
|
36
|
+
|
|
37
|
+
In the web UI: **Dashboard → Add device**. Copy the device ID it shows, then
|
|
38
|
+
add the device to `~/.configstash/config.yaml`:
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
devices:
|
|
42
|
+
- name: "Office MikroTik"
|
|
43
|
+
device_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # from the web UI
|
|
44
|
+
host: 192.168.88.1
|
|
45
|
+
device_type: mikrotik_routeros # mikrotik_routeros | ubiquiti_edgerouter | ubiquiti_edgeswitch | ubiquiti_unifiswitch
|
|
46
|
+
username: admin
|
|
47
|
+
password: "your-ssh-password"
|
|
48
|
+
port: 22
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> Tip: create a dedicated read-only SSH user on the device for backups.
|
|
52
|
+
|
|
53
|
+
### 5. Test and run (2 min)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
configstash-agent test # dry run: SSH connect + collect, nothing sent
|
|
57
|
+
configstash-agent run # collect and upload your first backup
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Open the web UI — your backup is there. Done. 🎉
|
|
61
|
+
|
|
62
|
+
### 6. Keep it running
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
configstash-agent install-service # auto-start on boot (systemd / launchd)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
By default backups run every 6 hours (`schedule: "0 */6 * * *"` — standard
|
|
69
|
+
cron syntax, edit in config.yaml) with a heartbeat every 5 minutes.
|
|
70
|
+
|
|
71
|
+
## No devices yet? Try demo mode
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
configstash-agent demo --api-url https://api.yourdomain.com --token cst_agent_... --repeat 3
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Creates a virtual MikroTik and uploads realistic configs with changes between
|
|
78
|
+
runs — great for seeing the diff viewer in action.
|
|
79
|
+
|
|
80
|
+
## All commands
|
|
81
|
+
|
|
82
|
+
| Command | What it does |
|
|
83
|
+
|---------|--------------|
|
|
84
|
+
| `init` | Interactive config creation |
|
|
85
|
+
| `test` | Dry run: SSH to all devices, don't upload |
|
|
86
|
+
| `run` | One-shot: collect and upload all devices |
|
|
87
|
+
| `start` | Foreground daemon on cron schedule (`-d` to background) |
|
|
88
|
+
| `stop` / `status` | Manage the running daemon |
|
|
89
|
+
| `install-service` / `uninstall-service` | systemd/launchd auto-start |
|
|
90
|
+
| `demo` | Fake device backups, no SSH needed |
|
|
91
|
+
| `uninstall` | Remove agent and local data (cloud backups stay) |
|
|
92
|
+
|
|
93
|
+
## Docker
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
cp config.example.yaml config.yaml # edit it
|
|
97
|
+
docker compose up -d
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
On Linux, uncomment `network_mode: host` in `docker-compose.yml` if your
|
|
101
|
+
devices aren't reachable from the container network.
|
|
102
|
+
|
|
103
|
+
## Notes
|
|
104
|
+
|
|
105
|
+
- Failed uploads are queued in `~/.configstash/pending/` and retried on the
|
|
106
|
+
next run — safe across API downtime.
|
|
107
|
+
- All local state lives in `~/.configstash/` (mode `700`).
|
|
108
|
+
- Always use an `https://` API URL in production — the agent warns otherwise.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|