Skip to content

hatamiarash7/Salt-Server-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salt Server Parser

made-with-python GitHub release Pylint CodeQL

Generate SSH config from Salt server lists

Requirements

  • Python 3.9+

How to use

It's your servers.sls file:

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:

python main.py <servers.sls> <output> <ssh port> <ssh user> <mode>

Example

python main.py /Salt/pillar/dev/servers.sls out.txt 22 arash Staging

Output

#------- 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.pub

Host 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