Learning to optimize my Ansible role to automatically populate the .ssh/config file based on my inventory has been beneficial. Managing the file remotely was very slow. I am switching to using ansible.builtin.slurp, ansible.builtin.set_fact, and ansible.builtin.copy.

Result: On the localhost, the time decreased from 20 seconds to 13 seconds. On a remote host, my script previously took over 2 minutes; now it runs in just under 20 seconds!

#ansible #homelab #selfthosted #selfthosting #ssh

@lucas3d Interesting, I'm looking forward for the full code to better understand the use case.
@C_Duv It’s one of the roles for me tools to automatically set up my homelab based on my inventory. This role is completed,and more are in development.