@@ -179,6 +179,12 @@ var addTelApp = func(ctx context.Context, podExecClient splutil.PodExecClientImp
179179 // Create pod exec client
180180 crKind := cr .GetObjectKind ().GroupVersionKind ().Kind
181181
182+ adminPwd , err := splutil .GetSpecificSecretTokenFromPod (ctx , podExecClient .GetClient (), podExecClient .GetTargetPodName (), cr .GetNamespace (), "password" )
183+ if err != nil {
184+ scopedLog .Error (err , "failed to retrieve admin password from pod secret" )
185+ return err
186+ }
187+
182188 // Commands to run on pods
183189 var command1 , command2 string
184190
@@ -188,14 +194,14 @@ var addTelApp = func(ctx context.Context, podExecClient splutil.PodExecClientImp
188194 command1 = fmt .Sprintf (createTelAppNonShcString , telAppConfString , telAppDefMetaConfString )
189195
190196 // App reload
191- command2 = telAppReloadString
197+ command2 = fmt . Sprintf ( telAppReloadString , adminPwd )
192198
193199 } else {
194200 // Create dir on pods
195201 command1 = fmt .Sprintf (createTelAppShcString , shcAppsLocationOnDeployer , shcAppsLocationOnDeployer , telAppConfString , shcAppsLocationOnDeployer , telAppDefMetaConfString , shcAppsLocationOnDeployer )
196202
197203 // Bundle push
198- command2 = fmt .Sprintf (applySHCBundleCmdStr , GetSplunkStatefulsetURL (cr .GetNamespace (), SplunkSearchHead , cr .GetName (), 0 , false ), "/tmp/status.txt" )
204+ command2 = fmt .Sprintf (applySHCBundleCmdStr , GetSplunkStatefulsetURL (cr .GetNamespace (), SplunkSearchHead , cr .GetName (), 0 , false ), adminPwd , "/tmp/status.txt" )
199205 }
200206
201207 // Run the commands on Splunk pods
@@ -741,10 +747,16 @@ func installApp(rctx context.Context, localCtx *localScopePlaybookContext, cr sp
741747 worker .appDeployInfo .AppPackageTopFolder = appTopFolder
742748 }
743749
750+ adminPwd , err := splutil .GetSpecificSecretTokenFromPod (rctx , worker .client , localCtx .podExecClient .GetTargetPodName (), cr .GetNamespace (), "password" )
751+ if err != nil {
752+ scopedLog .Error (err , "failed to retrieve admin password from pod secret" )
753+ return err
754+ }
755+
744756 var command string
745757 if worker .appDeployInfo .IsUpdate {
746758 // App was already installed, update scenario
747- command = fmt .Sprintf ("/opt/splunk/bin/splunk install app %s -update 1 -auth admin:`cat /mnt/splunk-secrets/password` " , appPkgPathOnPod )
759+ command = fmt .Sprintf ("/opt/splunk/bin/splunk install app %s -update 1 -auth admin:%s " , appPkgPathOnPod , adminPwd )
748760 } else {
749761 // install the app only if it was not already installed
750762 // we can come to this block if post installation failed
@@ -763,7 +775,7 @@ func installApp(rctx context.Context, localCtx *localScopePlaybookContext, cr sp
763775 return nil
764776 }
765777
766- command = fmt .Sprintf ("/opt/splunk/bin/splunk install app %s -auth admin:`cat /mnt/splunk-secrets/password` " , appPkgPathOnPod )
778+ command = fmt .Sprintf ("/opt/splunk/bin/splunk install app %s -auth admin:%s " , appPkgPathOnPod , adminPwd )
767779 }
768780
769781 streamOptions := splutil .NewStreamOptionsObject (command )
@@ -795,7 +807,13 @@ func isAppAlreadyInstalled(ctx context.Context, cr splcommon.MetaObject, podExec
795807
796808 scopedLog .Info ("check app's installation state" )
797809
798- command := fmt .Sprintf ("/opt/splunk/bin/splunk list app %s -auth admin:`cat /mnt/splunk-secrets/password`| grep ENABLED" , appTopFolder )
810+ adminPwd , err := splutil .GetSpecificSecretTokenFromPod (ctx , podExecClient .GetClient (), podExecClient .GetTargetPodName (), cr .GetNamespace (), "password" )
811+ if err != nil {
812+ scopedLog .Error (err , "failed to retrieve admin password from pod secret" )
813+ return false , err
814+ }
815+
816+ command := fmt .Sprintf ("/opt/splunk/bin/splunk list app %s -auth admin:%s| grep ENABLED" , appTopFolder , adminPwd )
799817
800818 streamOptions := splutil .NewStreamOptionsObject (command )
801819
@@ -1736,7 +1754,12 @@ func (shcPlaybookContext *SHCPlaybookContext) triggerBundlePush(ctx context.Cont
17361754 shcPlaybookContext .setLivenessProbeLevel (ctx , livenessProbeLevelOne )
17371755
17381756 // Trigger bundle push
1739- cmd := fmt .Sprintf (applySHCBundleCmdStr , shcPlaybookContext .searchHeadCaptainURL , shcBundlePushStatusCheckFile )
1757+ adminPwd , err := splutil .GetSpecificSecretTokenFromPod (ctx , shcPlaybookContext .client , shcPlaybookContext .podExecClient .GetTargetPodName (), shcPlaybookContext .cr .GetNamespace (), "password" )
1758+ if err != nil {
1759+ scopedLog .Error (err , "failed to retrieve admin password from pod secret" )
1760+ return err
1761+ }
1762+ cmd := fmt .Sprintf (applySHCBundleCmdStr , shcPlaybookContext .searchHeadCaptainURL , adminPwd , shcBundlePushStatusCheckFile )
17401763 scopedLog .Info ("Triggering bundle push" , "command" , cmd )
17411764 streamOptions := splutil .NewStreamOptionsObject (cmd )
17421765 stdOut , stdErr , err := shcPlaybookContext .podExecClient .RunPodExecCommand (ctx , streamOptions , []string {"/bin/sh" })
@@ -1889,7 +1912,12 @@ func (idxcPlaybookContext *IdxcPlaybookContext) isBundlePushComplete(ctx context
18891912 reqLogger := log .FromContext (ctx )
18901913 scopedLog := reqLogger .WithName ("isBundlePushComplete" ).WithValues ("crName" , idxcPlaybookContext .cr .GetName (), "namespace" , idxcPlaybookContext .cr .GetNamespace ())
18911914
1892- streamOptions := splutil .NewStreamOptionsObject (idxcShowClusterBundleStatusStr )
1915+ adminPwd , err := splutil .GetSpecificSecretTokenFromPod (ctx , idxcPlaybookContext .client , idxcPlaybookContext .podExecClient .GetTargetPodName (), idxcPlaybookContext .cr .GetNamespace (), "password" )
1916+ if err != nil {
1917+ scopedLog .Error (err , "failed to retrieve admin password from pod secret" )
1918+ return false
1919+ }
1920+ streamOptions := splutil .NewStreamOptionsObject (fmt .Sprintf (idxcShowClusterBundleStatusStr , adminPwd ))
18931921 stdOut , stdErr , err := idxcPlaybookContext .podExecClient .RunPodExecCommand (ctx , streamOptions , []string {"/bin/sh" })
18941922 if err == nil && strings .Contains (stdOut , "cluster_status=None" ) && ! strings .Contains (stdOut , "last_bundle_validation_status=failure" ) {
18951923 scopedLog .Info ("IndexerCluster Bundle push complete" )
@@ -1912,7 +1940,12 @@ func (idxcPlaybookContext *IdxcPlaybookContext) triggerBundlePush(ctx context.Co
19121940
19131941 // Reduce the liveness probe level
19141942 idxcPlaybookContext .setLivenessProbeLevel (ctx , livenessProbeLevelOne )
1915- streamOptions := splutil .NewStreamOptionsObject (applyIdxcBundleCmdStr )
1943+ adminPwd , err := splutil .GetSpecificSecretTokenFromPod (ctx , idxcPlaybookContext .client , idxcPlaybookContext .podExecClient .GetTargetPodName (), idxcPlaybookContext .cr .GetNamespace (), "password" )
1944+ if err != nil {
1945+ scopedLog .Error (err , "failed to retrieve admin password from pod secret" )
1946+ return err
1947+ }
1948+ streamOptions := splutil .NewStreamOptionsObject (fmt .Sprintf (applyIdxcBundleCmdStr , adminPwd ))
19161949 stdOut , stdErr , err := idxcPlaybookContext .podExecClient .RunPodExecCommand (ctx , streamOptions , []string {"/bin/sh" })
19171950
19181951 // If the error is due to a bundle which is already present, don't do anything.
@@ -2068,12 +2101,17 @@ func handleEsappPostinstall(rctx context.Context, preCtx *premiumAppScopePlayboo
20682101 var command string
20692102
20702103 // Create CLI command
2104+ adminPwd , err := splutil .GetSpecificSecretTokenFromPod (rctx , preCtx .client , preCtx .localCtx .podExecClient .GetTargetPodName (), cr .GetNamespace (), "password" )
2105+ if err != nil {
2106+ scopedLog .Error (err , "failed to retrieve admin password from pod secret" )
2107+ return err
2108+ }
20712109 sslEn := getSslCliOption (appSrcSpec )
20722110 if cr .GetObjectKind ().GroupVersionKind ().Kind != "SearchHeadCluster" {
2073- command = fmt .Sprintf ("/opt/splunk/bin/splunk search '| essinstall --ssl_enablement %s' -auth admin:`cat /mnt/splunk-secrets/password` " , sslEn )
2111+ command = fmt .Sprintf ("/opt/splunk/bin/splunk search '| essinstall --ssl_enablement %s' -auth admin:%s " , sslEn , adminPwd )
20742112 } else {
20752113 // Pass an extra parameter for SHC deployer in post install command
2076- command = fmt .Sprintf ("/opt/splunk/bin/splunk search '| essinstall --ssl_enablement %s --deployment_type shc_deployer' -auth admin:`cat /mnt/splunk-secrets/password` " , sslEn )
2114+ command = fmt .Sprintf ("/opt/splunk/bin/splunk search '| essinstall --ssl_enablement %s --deployment_type shc_deployer' -auth admin:%s " , sslEn , adminPwd )
20772115 }
20782116
20792117 streamOptions := splutil .NewStreamOptionsObject (command )
0 commit comments