From 72c8b75e22181e3c4ef837c844ede01168693a42 Mon Sep 17 00:00:00 2001 From: freezed <git-expect-noreply@freezed.me> Date: Thu, 5 Jan 2023 23:45:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Improve=20ssh=20config=20t?= =?UTF-8?q?ask?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/user_cfg/templates/ssh-config.j2 | 43 ++++++++++++++++++++++++++ tasks/user_cfg/templates/ssh_config.j2 | 13 -------- 2 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 tasks/user_cfg/templates/ssh-config.j2 delete mode 100644 tasks/user_cfg/templates/ssh_config.j2 diff --git a/tasks/user_cfg/templates/ssh-config.j2 b/tasks/user_cfg/templates/ssh-config.j2 new file mode 100644 index 0000000..a4cd8b8 --- /dev/null +++ b/tasks/user_cfg/templates/ssh-config.j2 @@ -0,0 +1,43 @@ +#jinja2:lstrip_blocks: True +# ############################################# # +# This file is managed by Ansible # +# https://lab.frogg.it/freezed/ansible-debian # +# ############################################# # + +{% if inventory_hostname in groups['station'] or inventory_hostname in groups['backup'] %} +# WAN + {% for host in groups['production'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} +{% endif %} + +{% if inventory_hostname in groups['station'] or inventory_hostname in groups['production'] %} +# BKP + {% for host in groups['backup'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} +{% endif %} + +{% if inventory_hostname in groups['station'] %} +# DEV + {% for host in groups['devel'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} + +# LOCAL + {% for host in groups['station'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + {% endfor %} +{% endif %} diff --git a/tasks/user_cfg/templates/ssh_config.j2 b/tasks/user_cfg/templates/ssh_config.j2 deleted file mode 100644 index 331ab2a..0000000 --- a/tasks/user_cfg/templates/ssh_config.j2 +++ /dev/null @@ -1,13 +0,0 @@ -#jinja2:lstrip_blocks: True -# ############################################# # -# This file is managed by Ansible # -# https://lab.frogg.it/freezed/ansible-debian # -# ############################################# # - -{% for host in groups['all'] %} -Host {{ host }} - User {{ hostvars[host]['my_user'] }} - Hostname {{ hostvars[host]['ansible_host'] }} - Port {{ hostvars[host]['ansible_port'] }} - -{% endfor %} -- GitLab