1+ #jinja2: trim_blocks:False
12#####
23##### The identity scope we are operating in
34##### Used to output the OpenStack project ID as a fact for provisioned hosts
@@ -233,6 +234,14 @@ resource "openstack_networking_port_v2" "{{ partition.name }}" {
233234
234235{% endfor %}
235236
237+ #####
238+ ##### Deploy key
239+ #####
240+ {% if cluster_ssh_private_key_file is not defined %}
241+ resource " openstack_compute_keypair_v2" " cluster_keypair" {
242+ name = " {{ cluster_name }}-deploy-key"
243+ }
244+ {% endif %}
236245
237246#####
238247##### Cluster nodes
@@ -255,8 +264,18 @@ resource "openstack_compute_instance_v2" "login" {
255264 user_data = <<-EOF
256265 #cloud-config
257266 ssh_authorized_keys:
258- - {{ cluster_deploy_ssh_public_key } }
267+ {%- if cluster_user_ssh_public_key is defined % }
259268 - {{ cluster_user_ssh_public_key }}
269+ {%- endif %}
270+ {%- if cluster_deploy_ssh_public_key is defined %}
271+ - {{ cluster_deploy_ssh_public_key }}
272+ {%- endif %}
273+ {%- if cluster_ssh_private_key_file is not defined %}
274+ - " ${openstack_compute_keypair_v2.cluster_keypair.public_key}"
275+ {%- endif %}
276+ {%- for ssh_key in cluster_deploy_ssh_keys_extra %}
277+ - {{ ssh_key }}
278+ {%- endfor %}
260279 EOF
261280}
262281
@@ -302,8 +321,18 @@ resource "openstack_compute_instance_v2" "control" {
302321 user_data = <<-EOF
303322 #cloud-config
304323 ssh_authorized_keys:
305- - {{ cluster_deploy_ssh_public_key } }
324+ {%- if cluster_user_ssh_public_key is defined % }
306325 - {{ cluster_user_ssh_public_key }}
326+ {%- endif %}
327+ {%- if cluster_deploy_ssh_public_key is defined %}
328+ - {{ cluster_deploy_ssh_public_key }}
329+ {%- endif %}
330+ {%- if cluster_ssh_private_key_file is not defined %}
331+ - " ${openstack_compute_keypair_v2.cluster_keypair.public_key}"
332+ {%- endif %}
333+ {%- for ssh_key in cluster_deploy_ssh_keys_extra %}
334+ - {{ ssh_key }}
335+ {%- endfor %}
307336 fs_setup:
308337 - label: state
309338 filesystem: ext4
@@ -335,10 +364,21 @@ resource "openstack_compute_instance_v2" "{{ partition.name }}" {
335364 user_data = <<-EOF
336365 #cloud-config
337366 ssh_authorized_keys:
338- - {{ cluster_deploy_ssh_public_key } }
367+ {%- if cluster_user_ssh_public_key is defined % }
339368 - {{ cluster_user_ssh_public_key }}
369+ {%- endif %}
370+ {%- if cluster_deploy_ssh_public_key is defined %}
371+ - {{ cluster_deploy_ssh_public_key }}
372+ {%- endif %}
373+ {%- if cluster_ssh_private_key_file is not defined %}
374+ - " ${openstack_compute_keypair_v2.cluster_keypair.public_key}"
375+ {%- endif %}
376+ {%- for ssh_key in cluster_deploy_ssh_keys_extra %}
377+ - {{ ssh_key }}
378+ {%- endfor %}
340379 EOF
341380}
381+
342382{% endfor %}
343383
344384#####
0 commit comments