https://github.com/hatamiarash7/salt-server-parser
Generate SSH config from Salt server lists
https://github.com/hatamiarash7/salt-server-parser
salt saltstack ssh ssh-config ssh-generator
Last synced: 8 months ago
JSON representation
Generate SSH config from Salt server lists
- Host: GitHub
- URL: https://github.com/hatamiarash7/salt-server-parser
- Owner: hatamiarash7
- License: gpl-3.0
- Created: 2022-09-26T10:41:50.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-28T15:08:43.000Z (8 months ago)
- Last Synced: 2025-01-28T16:23:16.111Z (8 months ago)
- Topics: salt, saltstack, ssh, ssh-config, ssh-generator
- Language: Python
- Homepage:
- Size: 101 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Salt Server Parser
[](https://www.python.org/) [](https://GitHub.com/hatamiarash7/Salt-Server-Parser/releases/) [](https://github.com/hatamiarash7/Salt-Server-Parser/actions/workflows/pylint.yml) [](https://github.com/hatamiarash7/Salt-Server-Parser/actions/workflows/codeql-analysis.yml)
Generate SSH config from Salt server lists
## Requirements
- Python 3.9+
## How to use
It's your `servers.sls` file:
```salt
servers:
lab-1001:
main_ip: 1.2.3.4
...
...
lab-1002:
main_ip: 4.5.6.7
...
...
...
...```
> **Note**: Add/remove extra info from `main.py` file. For example `IdentityFile`, `IdentityAgent`, etc
Run:
```bash
python main.py
```## Example
```bash
python main.py /Salt/pillar/dev/servers.sls out.txt 22 arash Staging
```## Output
```text
#------- Staging Servers ------#Host lab-1001
HostName 1.2.3.4
Port 22
User user
IdentitiesOnly yes
IdentityAgent ~/.gnupg/S.gpg-agent.ssh
IdentityFile ~/.ssh/id_rsa_yubikey.pubHost lab-1002
HostName 4.5.6.7
Port 22
User user
IdentitiesOnly yes
IdentityAgent ~/.gnupg/S.gpg-agent.ssh
IdentityFile ~/.ssh/id_rsa_yubikey.pub
```Also you will have two another files:
- A `ip-list.json` file containing all IPs will be generated for further use.
- A `server-list.json` file containing all servers with their IP based on `role`, `zone`, `provider` and `code`. There is an `other` key for unknown servers. You can Change `__create_list()` function to fit your needs.
- A `server-list.toml` file to use with [WireGuard-Config-Generator](https://github.com/hatamiarash7/WireGuard-Config-Generator)