yioda / ansible-inventory-to-ssh-config

This is a python tool for updating ssh config from ansible inventory file.
MIT License
25 stars 6 forks source link

Support for ansible_ssh_private_key_file #7

Closed timd98 closed 1 year ago

timd98 commented 1 year ago

Hi yioda,

I just copied your "user" part and changed it to "identityfile".

In Ansible the variable is called "ansible_ssh_private_key_file" and in ssh config its called "IdentityFile".

Thank you for the nice tool, it helps alot! Greetings Tim

yioda commented 1 year ago

Hi @timd98,

Great suggestion! I would merge this PR first, then would release a new version to Pypi as long as I have free time.

BTW,
since these hosts' information are updated from Ansible playbook, I think it should not affect the original ~/.ssh/config. So I'm planning to change the default path to ~/.ssh/config.d/ansible.config instead of the original ~/.ssh/config.

Then include it in ~/.ssh/config by:

# Include just this config
Include config.d/ansible.config

# or include all in config.d
Include config.d/*

But some older system seems doesn't support Include option in ssh config, I'm keeping to figure out a way to handle this,

Still, thanks for improving this project!

yioda commented 1 year ago

I've already build a new version pkg to pypi https://pypi.org/project/ansible-inventory-to-ssh-config/1.1.0/

and here's the release note's: https://github.com/yioda/ansible-inventory-to-ssh-config/releases/tag/1.1.0