From 97433e13535d27ffd9b7c76bf934812e9a345cfd Mon Sep 17 00:00:00 2001 From: Jiri Podivin Date: Tue, 4 Jun 2024 15:44:30 +0200 Subject: [PATCH] Sorting ssh keys before adding them to ansibleee resource Signed-off-by: Jiri Podivin --- pkg/util/ansible_execution.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/util/ansible_execution.go b/pkg/util/ansible_execution.go index 6fa54fc30..19b0d38cc 100644 --- a/pkg/util/ansible_execution.go +++ b/pkg/util/ansible_execution.go @@ -133,7 +133,15 @@ func AnsibleExecution( ansibleEE.Spec.ExtraVars["edpm_services_override"] = json.RawMessage([]byte(fmt.Sprintf("\"%s\"", deployment.Spec.ServicesOverride))) } - for sshKeyNodeName, sshKeySecret := range sshKeySecrets { + // Sort keys of the ssh secret map + sshKeys := make([]string, 0) + for k := range sshKeySecrets { + sshKeys = append(sshKeys, k) + } + sort.Strings(sshKeys) + + for _, sshKeyNodeName := range sshKeys { + sshKeySecret := sshKeySecrets[sshKeyNodeName] if service.Spec.DeployOnAllNodeSets { sshKeyName = fmt.Sprintf("ssh-key-%s", sshKeyNodeName) sshKeyMountSubPath = fmt.Sprintf("ssh_key_%s", sshKeyNodeName)