Ansible inventory file to ssh config
This is a Python tool for updating the SSH config from the Ansible inventory file.
Dependencies
Install
$ pip install ansible-inventory-to-ssh-config
From Github:
$ pip install git+https://github.com/yioda/ansible-inventory-to-ssh-config
Local install
$ git clone https://github.com/yioda/ansible-inventory-to-ssh-config.git
$ pip install .
Usage
$ aitsc -h # or ansible-inventory-to-ssh-config -h
usage: aitsc [-h] [-v] [-o OUTPUT] [-d] [-b] [-O] inventory_file
positional arguments:
inventory_file ansible inventory file
options:
-h, --help show this help message and exit
-v, --version show program version number and exit
-o OUTPUT, --output OUTPUT
ssh config output path (default: ~/.ssh/config.ansible)
-d, --dry-run show new configurations without updating file
-b, --with-backup update with backup
-O, --override override whole config, this would remove those hosts undefined in playbook
# Update ~/.ssh/config.ansible from specified inventory file
$ aitsc $INVENTORY_FILE
# Update with backup
$ aitsc $INVENTORY_FILE --with-backup
# Output as a new file
$ aitsc $INVENTORY_FILE -o new_ssh_config
# Show content without output
$ aitsc $INVENTORY_FILE -d
# Override while config
$ aitsc $INVENTORY_FILE -O
Example
# Input (Inventory File)
$ cat hosts
[group_1]
node1 ansible_ssh_host=192.168.0.5
node2 ansible_ssh_host=192.168.0.6
[group_2]
node3 ansible_host=192.168.0.7 ansible_ssh_private_key_file=~/.ssh/id_rsa_for_ansible
node4 ansible_host=192.168.0.8 ansible_port=10422 ansible_user=foo
# Commnad
$ aitsc hosts -o newconfig
Inventory: hosts
Target: newconfig
# Output (SSH Config Format)
$ cat new_ssh_config
Host node1
HostName 192.168.0.5
Host node2
HostName 192.168.0.6
Host node3
HostName 192.168.0.7
IdentityFile ~/.ssh/id_rsa_for_ansible
Host node4
HostName 192.168.0.8
Port 10422
User foo
Metadata
Release files for ansible-inventory-to-ssh-config 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ansible_inventory_to_ssh_config-1.1.2.tar.gz | 8.3 kB | Without provenance | Details for ansible_inventory_to_ssh_config-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ansible_inventory_to_ssh_config-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for ansible_inventory_to_ssh_config-1.1.2-py3-none-any.whl |
Total release size: 14.1 kB
Release files / ansible_inventory_to_ssh_config-1.1.2.tar.gz
| Download URL | ansible_inventory_to_ssh_config-1.1.2.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a8bf440c92836c8348643349477263c0532050cf9baa374b4631f8e12b2d08d
|
|
BLAKE2b-256 checksum How to use checksums |
2a100ff409b9856d32a5b263f04a25c7d8d5d04b3596cdd1ce67cc5592e3b11d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / ansible_inventory_to_ssh_config-1.1.2-py3-none-any.whl
| Download URL | ansible_inventory_to_ssh_config-1.1.2-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc9fb87560c93dc9ecae2fb09a378c031e9f2500159b2e5fd65a73ce65349bf2
|
|
BLAKE2b-256 checksum How to use checksums |
07c7664682731f22835057b131b1c6e3ebefb56f8f5d2322cfa6656fc8223ee6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for ansible-inventory-to-ssh-config 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.