vm/install: Handle non-22000 SSH ports
authornicoo <nicoo@realraum.at>
Wed, 13 Jun 2018 17:36:28 +0000 (19:36 +0200)
committernicoo <nicoo@realraum.at>
Sun, 17 Jun 2018 10:05:34 +0000 (12:05 +0200)
ansible/hosts.ini
ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2

index d67f69e..c165125 100644 (file)
@@ -2,6 +2,8 @@
 host_domain=realraum.at
 ansible_host={{ inventory_hostname }}.{{ host_domain }}
 ansible_user=root
+ansible_port=22000
+
 
 [net-zone-mgmt]
 torwaechter
index 6cf4b9b..d802418 100644 (file)
@@ -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 %}