From 5884318116ea9c0e45c2d34609cadc7f3b6eb7f1 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 25 Sep 2024 21:03:01 +0200 Subject: [PATCH] Allow to apply custom configuration to Nova SSH config In case compute nodes using non-standard SSH port or some other hacky connection between each other, deployers might need to supply extra configuration inside it. community.general.ssh_config module was not used, as it requires extra `paramiko` module to be installed on each destination host. Change-Id: Ic79aa391e729adf61f5653dd3cf72fee1708e2f5 --- defaults/main.yml | 6 ++++++ files/ssh_config | 2 -- releasenotes/notes/custom_ssh_config-46c443e077b3386b.yaml | 7 +++++++ tasks/nova_compute.yml | 4 ++-- templates/ssh_config.j2 | 5 +++++ 5 files changed, 20 insertions(+), 4 deletions(-) delete mode 100644 files/ssh_config create mode 100644 releasenotes/notes/custom_ssh_config-46c443e077b3386b.yaml create mode 100644 templates/ssh_config.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 58a0a5ba..9ca4193c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -769,6 +769,12 @@ nova_pki_console_install_certificates: mode: "0640" condition: "{{ nova_pki_console_condition | bool }}" +# Extra settings which will be applied for `nova` user for offline +# migrations and resizes. Example: +# nova_ssh_custom_config: +# Port: 2022 +nova_ssh_custom_config: {} + # host which holds the ssh certificate authority nova_ssh_keypairs_setup_host: "{{ openstack_ssh_keypairs_setup_host | default('localhost') }}" diff --git a/files/ssh_config b/files/ssh_config deleted file mode 100644 index f30d239b..00000000 --- a/files/ssh_config +++ /dev/null @@ -1,2 +0,0 @@ -Host * - StrictHostKeyChecking no diff --git a/releasenotes/notes/custom_ssh_config-46c443e077b3386b.yaml b/releasenotes/notes/custom_ssh_config-46c443e077b3386b.yaml new file mode 100644 index 00000000..0ffee560 --- /dev/null +++ b/releasenotes/notes/custom_ssh_config-46c443e077b3386b.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Added variable ``nova_ssh_custom_config`` which allows to apply + extra configuration for SSH connection established by Nova Compute + while perfroming offline migrations or resizes. + Can be leveraged to define a custom SSH port or ProxyJump. diff --git a/tasks/nova_compute.yml b/tasks/nova_compute.yml index 0d7f36a7..341afe25 100644 --- a/tasks/nova_compute.yml +++ b/tasks/nova_compute.yml @@ -23,8 +23,8 @@ - always - name: Create the nova SSH config file - copy: - src: "ssh_config" + template: + src: "ssh_config.j2" dest: "{{ nova_system_home_folder }}/.ssh/config" owner: "{{ nova_system_user_name }}" group: "{{ nova_system_user_name }}" diff --git a/templates/ssh_config.j2 b/templates/ssh_config.j2 new file mode 100644 index 00000000..b8e994cf --- /dev/null +++ b/templates/ssh_config.j2 @@ -0,0 +1,5 @@ +Host * + StrictHostKeyChecking no +{% for key, value in nova_ssh_custom_config.items() %} + {{ key }} {{ value }} +{% endfor %}