main.yml 622 B

123456789101112131415161718
  1. - blockinfile:
  2. dest: /etc/ssh/ssh_config
  3. marker: '# ANSIBLE SSH CONFIG {mark}'
  4. block: |-
  5. {% for host in ssh_config_hosts %}
  6. {% set host_config = ssh_config_hosts[host] %}
  7. Host {{host}}
  8. {% if host_config.hostname is defined %}
  9. HostName {{host_config.hostname}}
  10. {% endif %}
  11. {% if host_config.user is defined %}
  12. User {{host_config.user}}
  13. {% endif %}
  14. {% if host_config.ssh_proxy is defined %}
  15. ProxyCommand ssh -W localhost:{{host_config.ssh_proxy.port}} {{host_config.ssh_proxy.host}}
  16. {% endif %}
  17. {% endfor %}
  18. become: yes