From 6c8cf34665615f599a5717d9d97ccf322fda4473 Mon Sep 17 00:00:00 2001 From: nicoo Date: Wed, 13 Jun 2018 19:36:28 +0200 Subject: [PATCH] vm/install: Handle non-22000 SSH ports --- ansible/hosts.ini | 2 ++ ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ansible/hosts.ini b/ansible/hosts.ini index d67f69e..c165125 100644 --- a/ansible/hosts.ini +++ b/ansible/hosts.ini @@ -2,6 +2,8 @@ host_domain=realraum.at ansible_host={{ inventory_hostname }}.{{ host_domain }} ansible_user=root +ansible_port=22000 + [net-zone-mgmt] torwaechter diff --git a/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 b/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 index 6cf4b9b..d802418 100644 --- a/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 +++ b/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 @@ -105,4 +105,6 @@ d-i preseed/late_command string \ in-target bash -c "passwd -d root && passwd -l root"; \ mkdir -p -m 0700 /target/root/.ssh; \ cp /authorized_keys /target/root/.ssh/; \ - in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port 22000/' -i /etc/ssh/sshd_config" +{% if hostvars[vmname].ansible_port is defined %} + in-target bash -c "sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[vmname].ansible_port }}/' -i /etc/ssh/sshd_config" +{% endif %} -- 1.7.10.4