From 7bf1e9708fd09791078a77f485a75efa62eb7791 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Wed, 21 Dec 2016 11:16:30 +0100 Subject: [PATCH] Try to fix creation of ssh-bastion.conf --- roles/bastion-ssh-config/tasks/main.yml | 6 ++++++ roles/bastion-ssh-config/templates/ssh-bastion.conf | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/roles/bastion-ssh-config/tasks/main.yml b/roles/bastion-ssh-config/tasks/main.yml index d1aae5ca8..a4ea57459 100644 --- a/roles/bastion-ssh-config/tasks/main.yml +++ b/roles/bastion-ssh-config/tasks/main.yml @@ -16,3 +16,9 @@ - name: create ssh bastion conf become: false template: src=ssh-bastion.conf dest="{{ playbook_dir }}/ssh-bastion.conf" + when: has_bastion + +- name: create empty bastion conf in case no bastion is used + become: false + copy: content="" dest="{{ playbook_dir }}/ssh-bastion.conf" + when: not has_bastion diff --git a/roles/bastion-ssh-config/templates/ssh-bastion.conf b/roles/bastion-ssh-config/templates/ssh-bastion.conf index 6bcc65dad..a201365b4 100644 --- a/roles/bastion-ssh-config/templates/ssh-bastion.conf +++ b/roles/bastion-ssh-config/templates/ssh-bastion.conf @@ -1,6 +1,4 @@ -{% if has_bastion %} {% set vars={'hosts': ''} %} -{% set user='' %} {% for h in groups['all'] %} {% if h != 'bastion' %} @@ -18,4 +16,3 @@ Host {{ bastion_ip }} Host {{ vars['hosts'] }} ProxyCommand ssh -W %h:%p {{ real_user }}@{{ bastion_ip }} StrictHostKeyChecking no -{% endif %} \ No newline at end of file