Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/openstackbaremetalset/baremetalhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ func BaremetalHostProvision(
// User data cloud-init secret
if userDataSecret == nil {
templateParameters := make(map[string]interface{})
templateParameters["AuthorizedKeys"] = strings.TrimSuffix(string(sshSecret.Data["authorized_keys"]), "\n")

// Import from https://github.com/openstack-k8s-operators/osp-director-operator/pull/1043
// Split the keys into a list of separate strings, as cloud-init wants a list
// (a single-key string also works, but if there multiple keys in that string
// then passing the keys as a string results in *none* of them working, so it
// is better to create a list always)
splitKeys := strings.Split(strings.TrimSuffix(string(sshSecret.Data["authorized_keys"]), "\n"), "\n")
templateParameters["AuthorizedKeys"] = splitKeys

templateParameters["HostName"] = bmhStatus.Hostname
//If Hostname is fqdn, use it
if !hostNameIsFQDN(bmhStatus.Hostname) && instance.Spec.DomainName != "" {
Expand Down
7 changes: 6 additions & 1 deletion templates/openstackbaremetalset/cloudinit/userdata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ hostname: {{ .HostName }}
fqdn: {{ .FQDN }}
users:
- name: {{ .CloudUserName }}
ssh-authorized-keys: {{ .AuthorizedKeys }}
ssh_authorized_keys:
{{ range $ssh_key := .AuthorizedKeys }}
{{ if not (eq $ssh_key "") }}
- {{ $ssh_key }}
{{ end }}
{{ end }}
sudo: ['ALL=(ALL) NOPASSWD:ALL']
shell: /bin/bash
{{- if (index . "NodeRootPassword") }}
Expand Down