Skip to content

Commit 880d528

Browse files
committed
Fix logic for public SSH deploy keys
1 parent 43ea30d commit 880d528

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

roles/cluster_infra/defaults/main.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,4 @@ cluster_groups_zenith:
5151
# Any hosts in the grafana and openondemand groups should go in the zenith group
5252
zenith: [grafana, openondemand]
5353

54-
# Deploy user SSH keys
55-
cluster_deploy_ssh_keys: >-
56-
{{
57-
cluster_deploy_ssh_additional_public_keys | default([]) +
58-
( [cluster_deploy_ssh_public_key]
59-
if cluster_deploy_ssh_public_key is defined
60-
else [] )
61-
}}
54+
cluster_deploy_ssh_keys_extra: []

roles/cluster_infra/templates/resources.tf.j2

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,16 @@ resource "openstack_compute_instance_v2" "login" {
264264
user_data = <<-EOF
265265
#cloud-config
266266
ssh_authorized_keys:
267+
{%- if cluster_user_ssh_public_key is defined %}
268+
- {{ cluster_user_ssh_public_key }}
269+
{%- endif %}
270+
{%- if cluster_deploy_ssh_public_key is defined %}
271+
- {{ cluster_deploy_ssh_public_key }}
272+
{%- endif %}
267273
{%- if cluster_ssh_private_key_file is not defined %}
268274
- "${openstack_compute_keypair_v2.cluster_keypair.public_key}"
269275
{%- endif %}
270-
{%- for ssh_key in cluster_deploy_ssh_keys %}
276+
{%- for ssh_key in cluster_deploy_ssh_keys_extra %}
271277
- {{ ssh_key }}
272278
{%- endfor %}
273279
EOF
@@ -315,10 +321,16 @@ resource "openstack_compute_instance_v2" "control" {
315321
user_data = <<-EOF
316322
#cloud-config
317323
ssh_authorized_keys:
324+
{%- if cluster_user_ssh_public_key is defined %}
325+
- {{ cluster_user_ssh_public_key }}
326+
{%- endif %}
327+
{%- if cluster_deploy_ssh_public_key is defined %}
328+
- {{ cluster_deploy_ssh_public_key }}
329+
{%- endif %}
318330
{%- if cluster_ssh_private_key_file is not defined %}
319331
- "${openstack_compute_keypair_v2.cluster_keypair.public_key}"
320332
{%- endif %}
321-
{%- for ssh_key in cluster_deploy_ssh_keys %}
333+
{%- for ssh_key in cluster_deploy_ssh_keys_extra %}
322334
- {{ ssh_key }}
323335
{%- endfor %}
324336
fs_setup:
@@ -352,10 +364,16 @@ resource "openstack_compute_instance_v2" "{{ partition.name }}" {
352364
user_data = <<-EOF
353365
#cloud-config
354366
ssh_authorized_keys:
367+
{%- if cluster_user_ssh_public_key is defined %}
368+
- {{ cluster_user_ssh_public_key }}
369+
{%- endif %}
370+
{%- if cluster_deploy_ssh_public_key is defined %}
371+
- {{ cluster_deploy_ssh_public_key }}
372+
{%- endif %}
355373
{%- if cluster_ssh_private_key_file is not defined %}
356374
- "${openstack_compute_keypair_v2.cluster_keypair.public_key}"
357375
{%- endif %}
358-
{%- for ssh_key in cluster_deploy_ssh_keys %}
376+
{%- for ssh_key in cluster_deploy_ssh_keys_extra %}
359377
- {{ ssh_key }}
360378
{%- endfor %}
361379
EOF

0 commit comments

Comments
 (0)