SSH Config and Ansible Host Generator and Why I am doing it this way?
By Fahad Ahammed
- 2 minutes read - 230 wordsI am recently playing the role as an SRE and that is why I have to deal with a lot of servers. Not only cloud once or clusters but also bare metals as well as Virtual Machines. For more systematic environment preparation, I have Gitlab pipeline. But for basic tasks like change the config on demand or check a specific directory or search something or any other unpredictable or repeated tasks, I need Ansible for better grasp from my local machine or Bastion server. So, what do I have to do?
- Create an entry to the .ssh/config file
- Create an entry ansible host file as inventory
Repeated tasks? For me, yes. I needed to manage these. So, created a python script
that takes several arguments and store it into Ansible inventory and as well as in .ssh/config file for future ease of access. It does give me a better configuration handling.
The script is in here: https://github.com/fahadahammed/ssh-config-ansible-inventory-generator
Let me share the current script here:
Now, it has some flow to manage.
Help
Need the DB to be initiated for the first time
How to insert host information to the Database?
How to generate ssh config and as well as ansible inventory file
I am getting a .ssh/config and hosts.json file from this script. There might be some other way but I am managing ssh configs and Ansible hosts with this tool.