Repository: chef/automate
Pull request #8516 (2024-07-27 05:22:32)

reloading postgresql config after pg restart, and add or remove node operation
### :nut_and_bolt: Description: What code changed, and why?

<!-- /!\ Please ensure that you are NOT disclosing any customer information without their consent /!\ -->

### :chains: Related Resources

### :+1: Definition of Done

### :athletic_shoe: How to Build and Test the Change

### :white_check_mark: Checklist

**All PRs** must tick these:

- [ ] I have read the [CONTRIBUTING document](https://github.com/chef/automate/blob/master/CONTRIBUTING.md).
- [ ] All commits signed-off for the [Developer Certification of Origin](https://github.com/chef/chef/blob/master/CONTRIBUTING.md#developer-certification-of-origin-dco).

With occasional exceptions, all PRs **from Progress employees** must tick these:

- [ ] Is the code clear? *(complicated code or lots of comments--subdivide and use well-named methods, meaningful variable names, etc.)*
- [ ] Consistency checked? *(user notifications, user prompts, visual patterns, code patterns, variable names)*
- [ ] Repeated code blocks eliminated? *(adapt and reuse existing components, blocks, functions, etc.)*
- [ ] Spelling, grammar, typos checked? *(at a minimum use `make spell` in any component directory)*
- [ ] Code well-formatted? *(indents, line breaks, etc. improve rather than hinder readability)*

All PRs **from Progress employees** should tick these if appropriate:

- [ ] Tests added/updated? (all new code needs new tests)
- [ ] Docs added/updated? (all customer-facing changes)

*Please add a note next to any checkbox above if you are NOT ticking it.*

### :camera: Screenshots, if applicable


netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *chef-automate* processing.


|  Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 66a14e9a97aed93660635f775dec18db170185e9 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/chef-automate/deploys/66a4841a3796c9000887f6f6 |
sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false) [2 New issues](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) [0.0% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) (required ≥ 80%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516)

![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension [![SonarLint](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/sonarlint-16px.png 'SonarLint')](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request) [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false) [2 New issues](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) [37.5% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) (required ≥ 80%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516)

![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension [![SonarLint](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/sonarlint-16px.png 'SonarLint')](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request) [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false) [2 New issues](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) [36.3% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) (required ≥ 80%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516)

![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension [![SonarLint](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/sonarlint-16px.png 'SonarLint')](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request) [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false) [2 New issues](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) [36.3% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) (required ≥ 80%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516)

![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension [![SonarLint](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/sonarlint-16px.png 'SonarLint')](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request) [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false) [2 New issues](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) [43.1% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) (required ≥ 80%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516)

![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension [![SonarLint](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/sonarlint-16px.png 'SonarLint')](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request) [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false) [2 New issues](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) [4.4% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) (required ≥ 80%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516)

![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension [![SonarLint](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/sonarlint-16px.png 'SonarLint')](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request) [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
sonarqube-for-infrastructure-prod[bot]: ## [![Quality Gate failed](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516) **Quality Gate failed**  
Failed conditions  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false) [2 New issues](https://sonar.progress.com/project/issues?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&resolved=false)  
[![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/failed-16px.png '')](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) [4.4% Coverage on New Code](https://sonar.progress.com/component_measures?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516&metric=new_coverage&view=list) (required ≥ 80%)  
  
[See analysis details on SonarQube](https://sonar.progress.com/dashboard?id=chef_automate_AYeOVEbqJ4YHsO5MtKWC&pullRequest=8516)

![](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension [![SonarLint](https://raw.githubusercontent.com/SonarSource/sonarqube-static-resources/master/v104/common/sonarlint-16px.png 'SonarLint')](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request) [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)

Patch:
diff --git a/VERSION b/VERSION
index 654d0231f..a9f6825d0 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-4.12.137
\ No newline at end of file
+4.12.138
\ No newline at end of file
diff --git a/components/automate-backend-deployment/README.md b/components/automate-backend-deployment/README.md
index e2e452a4b..9f52eb920 100644
--- a/components/automate-backend-deployment/README.md
+++ b/components/automate-backend-deployment/README.md
@@ -6,4 +6,3 @@ This provides the `automate-backend-deployment` package.
 This package will build a package using terraform/a2ha-terraform, inspecs, test, certs and Makefile.
 
 This is the heart of the a2ha because this component will set up a workspace for a2ha and all the a2ha command will get available after installing this package.
-
diff --git a/components/automate-cli/cmd/chef-automate/certRotate.go b/components/automate-cli/cmd/chef-automate/certRotate.go
index 602b9f603..a01e6d19d 100644
--- a/components/automate-cli/cmd/chef-automate/certRotate.go
+++ b/components/automate-cli/cmd/chef-automate/certRotate.go
@@ -149,7 +149,7 @@ type certRotateFlow struct {
 	writer      *cli.Writer
 	pullConfigs PullConfigs
 	log         logger.Logger
-	nodeUtils   *NodeUtilsImpl
+	nodeUtils   NodeOpUtils
 }
 
 type NodeIpHealth struct {
@@ -230,7 +230,11 @@ func init() {
 
 func certRotateCmdFunc(flagsObj *certRotateFlags) func(cmd *cobra.Command, args []string) error {
 	return func(cmd *cobra.Command, args []string) error {
-		log, err := logger.NewLogger("text", "info")
+		level := "info"
+		if globalOpts.debug {
+			level = "debug"
+		}
+		log, err := logger.NewLogger("text", level)
 		if err != nil {
 			return err
 		}
diff --git a/components/automate-cli/cmd/chef-automate/certRotateFromTemplate.go b/components/automate-cli/cmd/chef-automate/certRotateFromTemplate.go
index cb60020d8..785d83110 100644
--- a/components/automate-cli/cmd/chef-automate/certRotateFromTemplate.go
+++ b/components/automate-cli/cmd/chef-automate/certRotateFromTemplate.go
@@ -156,7 +156,7 @@ func (c *certRotateFlow) rotatePGCertAndRestartPGNode(pgIps []IP, statusSummary
 	}
 	c.writer.Println("restarting postgres service and reloading ha proxy")
 
-	return c.nodeUtils.postPGCertRotate(infra.Outputs.PostgresqlPrivateIps.Value, sshUtil, c.fileUtils, c.sshUtil)
+	return c.nodeUtils.postPGCertRotate(infra.Outputs.PostgresqlPrivateIps.Value, *sshUtil.getSSHConfig(), c.fileUtils, c.log)
 }
 
 func (c *certRotateFlow) rotatePGLeaderNodeCert(pgIps []IP, pgLeaderIpAndHealth *NodeIpHealth, infra *AutomateHAInfraDetails, sshUtil SSHUtil, currentCertsInfo *certShowCertificates, pgRootCA string, concurrent bool) error {
diff --git a/components/automate-cli/cmd/chef-automate/ha_node_add_aws.go b/components/automate-cli/cmd/chef-automate/ha_node_add_aws.go
index 16cd9591c..4d0cba2e7 100644
--- a/components/automate-cli/cmd/chef-automate/ha_node_add_aws.go
+++ b/components/automate-cli/cmd/chef-automate/ha_node_add_aws.go
@@ -8,6 +8,7 @@ import (
 	"github.com/chef/automate/components/automate-cli/pkg/status"
 	"github.com/chef/automate/components/automate-deployment/pkg/cli"
 	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
 )
@@ -194,12 +195,19 @@ func (ani *AddNodeAWSImpl) runDeploy() error {
 
 	// Restart all PostgreSQL nodes in order to apply the new configuration
 	if len(ani.flags.postgresqlIp) > 0 {
-		leader := getPGLeader(ani.statusSummary)
 		infra, err := getAutomateHAInfraDetails()
 		if err != nil {
 			return err
 		}
-		err = ani.nodeUtils.restartPgNodes(*leader, infra.Outputs.PostgresqlPrivateIps.Value, infra, ani.statusSummary)
+		level := "info"
+		if globalOpts.debug {
+			level = "debug"
+		}
+		log, err := logger.NewLogger("text", level)
+		if err != nil {
+			return err
+		}
+		err = ani.nodeUtils.postPGCertRotate(infra.Outputs.PostgresqlPrivateIps.Value, *ani.sshUtil.getSSHConfig(), ani.fileutils, log)
 		if err != nil {
 			return err
 		}
diff --git a/components/automate-cli/cmd/chef-automate/ha_node_add_onprem.go b/components/automate-cli/cmd/chef-automate/ha_node_add_onprem.go
index 55c8cd224..ed0426c27 100644
--- a/components/automate-cli/cmd/chef-automate/ha_node_add_onprem.go
+++ b/components/automate-cli/cmd/chef-automate/ha_node_add_onprem.go
@@ -11,6 +11,7 @@ import (
 	"github.com/chef/automate/components/automate-cli/pkg/status"
 	cli "github.com/chef/automate/components/automate-deployment/pkg/cli"
 	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 	"github.com/chef/automate/lib/stringutils"
 	"github.com/spf13/cobra"
 )
@@ -234,12 +235,19 @@ func (ani *AddNodeOnPremImpl) runDeploy() error {
 
 	// Restart all PostgreSQL nodes in order to apply the new configuration
 	if len(ani.postgresqlIp) > 0 {
-		leader := getPGLeader(ani.statusSummary)
 		infra, err := getAutomateHAInfraDetails()
 		if err != nil {
 			return err
 		}
-		err = ani.nodeUtils.restartPgNodes(*leader, infra.Outputs.PostgresqlPrivateIps.Value, infra, ani.statusSummary)
+		level := "info"
+		if globalOpts.debug {
+			level = "debug"
+		}
+		log, err := logger.NewLogger("text", level)
+		if err != nil {
+			return err
+		}
+		err = ani.nodeUtils.postPGCertRotate(infra.Outputs.PostgresqlPrivateIps.Value, *ani.sshUtil.getSSHConfig(), ani.fileutils, log)
 		if err != nil {
 			return err
 		}
diff --git a/components/automate-cli/cmd/chef-automate/ha_node_delete_aws.go b/components/automate-cli/cmd/chef-automate/ha_node_delete_aws.go
index 9dec34d85..4e99e9e20 100644
--- a/components/automate-cli/cmd/chef-automate/ha_node_delete_aws.go
+++ b/components/automate-cli/cmd/chef-automate/ha_node_delete_aws.go
@@ -11,6 +11,7 @@ import (
 	"github.com/chef/automate/components/automate-cli/pkg/status"
 	"github.com/chef/automate/components/automate-deployment/pkg/cli"
 	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 	"github.com/chef/automate/lib/stringutils"
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
@@ -270,12 +271,20 @@ func (dna *DeleteNodeAWSImpl) runDeploy() error {
 
 	// Restart all PostgreSQL nodes in order to apply the new configuration
 	if dna.nodeType == POSTGRESQL {
-		leader := getPGLeader(dna.statusSummary)
 		infra, err := getAutomateHAInfraDetailsFunc()
 		if err != nil {
 			return err
 		}
-		err = dna.nodeUtils.restartPgNodes(*leader, infra.Outputs.PostgresqlPrivateIps.Value, infra, dna.statusSummary)
+		level := "info"
+		if globalOpts.debug {
+			level = "debug"
+		}
+		log, err := logger.NewLogger("text", level)
+		if err != nil {
+			return err
+		}
+		fileUtils := &fileutils.FileSystemUtils{}
+		err = dna.nodeUtils.postPGCertRotate(infra.Outputs.PostgresqlPrivateIps.Value, *dna.sshUtil.getSSHConfig(), fileUtils, log)
 		if err != nil {
 			return err
 		}
diff --git a/components/automate-cli/cmd/chef-automate/ha_node_delete_onprem.go b/components/automate-cli/cmd/chef-automate/ha_node_delete_onprem.go
index bdf6db0c5..fca5a8229 100644
--- a/components/automate-cli/cmd/chef-automate/ha_node_delete_onprem.go
+++ b/components/automate-cli/cmd/chef-automate/ha_node_delete_onprem.go
@@ -9,6 +9,7 @@ import (
 	"github.com/chef/automate/components/automate-cli/pkg/status"
 	"github.com/chef/automate/components/automate-deployment/pkg/cli"
 	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 	"github.com/chef/automate/lib/stringutils"
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
@@ -281,12 +282,20 @@ func (dni *DeleteNodeOnPremImpl) runDeploy() error {
 
 	// Restart all PostgreSQL nodes in order to apply the new configuration
 	if dni.nodeType == POSTGRESQL {
-		leader := getPGLeader(dni.statusSummary)
 		infra, err := getAutomateHAInfraDetails()
 		if err != nil {
 			return err
 		}
-		err = dni.nodeUtils.restartPgNodes(*leader, infra.Outputs.PostgresqlPrivateIps.Value, infra, dni.statusSummary)
+		level := "info"
+		if globalOpts.debug {
+			level = "debug"
+		}
+		log, err := logger.NewLogger("text", level)
+		if err != nil {
+			return err
+		}
+		fileUtils := &fileutils.FileSystemUtils{}
+		err = dni.nodeUtils.postPGCertRotate(infra.Outputs.PostgresqlPrivateIps.Value, *dni.sshUtil.getSSHConfig(), fileUtils, log)
 		if err != nil {
 			return err
 		}
diff --git a/components/automate-cli/cmd/chef-automate/ha_node_operations_utils.go b/components/automate-cli/cmd/chef-automate/ha_node_operations_utils.go
index 38d747051..10ed33c93 100644
--- a/components/automate-cli/cmd/chef-automate/ha_node_operations_utils.go
+++ b/components/automate-cli/cmd/chef-automate/ha_node_operations_utils.go
@@ -16,6 +16,7 @@ import (
 	"github.com/chef/automate/components/automate-cli/pkg/status"
 	"github.com/chef/automate/components/automate-deployment/pkg/cli"
 	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 	"github.com/chef/automate/lib/platform/command"
 	"github.com/chef/automate/lib/sshutils"
 	"github.com/chef/automate/lib/stringutils"
@@ -83,6 +84,7 @@ type NodeOpUtils interface {
 	saveConfigToBastion() error
 	syncConfigToAllNodes(unreachableNodes map[string][]string) error
 	restartPgNodes(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error
+	postPGCertRotate(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error
 }
 
 type NodeUtilsImpl struct {
@@ -479,7 +481,10 @@ func (nu *NodeUtilsImpl) restartPgNodes(leaderNode NodeIpHealth, pgIps []string,
 	sshUtil := NewSSHUtil(newSSHConfig)
 	// restart followers
 	nu.writer.Println("trying to restaring follower node")
-	restartFollowerNodeAndWaitForhealthy(leaderNode, pgIps, infra, statusSummary, sshUtil, nu.writer)
+	err := restartFollowerNodeAndWaitForhealthy(leaderNode, pgIps, infra, statusSummary, sshUtil, nu.writer)
+	if err != nil {
+		return err
+	}
 	//restart leader
 	nu.writer.Println("trying to restaring leader node")
 	for _, pgIp := range pgIps {
@@ -498,7 +503,7 @@ func (nu *NodeUtilsImpl) restartPgNodes(leaderNode NodeIpHealth, pgIps []string,
 	return nil
 }
 
-func (nu *NodeUtilsImpl) postPGCertRotate(pgIps []string, sshUtil SSHUtil, fileUtils fileutils.FileUtils, sshUtilPkg sshutils.SSHUtil) error {
+func (nu *NodeUtilsImpl) postPGCertRotate(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
 
 	content, err := fileUtils.ReadFile(MANIFEST_AUTO_TFVARS)
 	if err != nil {
@@ -521,26 +526,21 @@ func (nu *NodeUtilsImpl) postPGCertRotate(pgIps []string, sshUtil SSHUtil, fileU
 	}
 
 	scriptContent := fmt.Sprintf(remotescripts.POST_CERT_ROTATE_PG, pgIdentVal, pgLeaderIdentVal, haProxyIdentVal)
-
-	file, err := os.CreateTemp(HAB_TMP_DIR, "pg-restart-*.sh")
+	filename, err := fileUtils.CreateTempFile(scriptContent, "pg-restart-*.sh", HAB_TMP_DIR)
 	if err != nil {
 		return fmt.Errorf("failed to create file %v", err)
 	}
-	defer os.Remove(file.Name())
-
-	_, err = file.WriteString(scriptContent)
-	if err != nil {
-		return fmt.Errorf("failed to write to temporary file %v", err)
-	}
+	defer fileUtils.RemoveFile(filename)
 
 	conf := sshutils.SSHConfig{
-		SshUser:    sshUtil.getSSHConfig().sshUser,
-		SshPort:    sshUtil.getSSHConfig().sshPort,
-		SshKeyFile: sshUtil.getSSHConfig().sshKeyFile,
-		Timeout:    sshUtil.getSSHConfig().timeout,
+		SshUser:    sshconfig.sshUser,
+		SshPort:    sshconfig.sshPort,
+		SshKeyFile: sshconfig.sshKeyFile,
+		Timeout:    sshconfig.timeout,
 	}
+	sshUtilPkg := sshutils.NewSSHUtilWithCommandExecutor(sshutils.NewSshClient(), log, command.NewExecExecutor())
 
-	excuteResults := sshUtilPkg.CopyFileToRemoteConcurrently(conf, file.Name(), PG_SCRIPT_NAME, PG_SCRIPT_PATH, false, pgIps)
+	excuteResults := sshUtilPkg.CopyFileToRemoteConcurrently(conf, filename, PG_SCRIPT_NAME, PG_SCRIPT_PATH, false, pgIps)
 
 	var isErr bool
 	for _, result := range excuteResults {
@@ -1086,21 +1086,6 @@ func removeRestrictedKeysFromSrcFile(srcString string) (string, error) {
 	}
 }
 
-func (nu *NodeUtilsImpl) restartHabSupOnBackend(service string) error {
-	remoteExcecutor := NewRemoteCmdExecutorWithoutNodeMap(&SSHUtilImpl{}, cli.NewWriter(os.Stdout, os.Stderr, os.Stdin))
-	infra, _, err := nu.getHaInfraDetails()
-	if err != nil {
-		return err
-	}
-	flags := &RestartCmdFlags{
-		postgresql: true,
-	}
-	restartCmdResults := make(chan restartCmdResult, 4)
-	runRestartCmdForBackend(infra, flags, remoteExcecutor, restartCmdResults)
-
-	return getChannelValue(restartCmdResults, printRestartOutput)
-}
-
 func getPGLeader(statusSummary StatusSummary) *NodeIpHealth {
 	ip, health := statusSummary.GetPGLeaderNode()
 	nodeIpHealth := NodeIpHealth{
@@ -1109,3 +1094,5 @@ func getPGLeader(statusSummary StatusSummary) *NodeIpHealth {
 	}
 	return &nodeIpHealth
 }
+
+var getPGLeaderFunc func(statusSummary StatusSummary) *NodeIpHealth = getPGLeader
diff --git a/components/automate-cli/cmd/chef-automate/mock_ha_node_operations_utils.go b/components/automate-cli/cmd/chef-automate/mock_ha_node_operations_utils.go
index 75e60c3d0..5d04d503c 100644
--- a/components/automate-cli/cmd/chef-automate/mock_ha_node_operations_utils.go
+++ b/components/automate-cli/cmd/chef-automate/mock_ha_node_operations_utils.go
@@ -1,5 +1,10 @@
 package main
 
+import (
+	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
+)
+
 type MockNodeUtilsImpl struct {
 	executeAutomateClusterCtlCommandAsyncfunc    func(command string, args []string, helpDocs string) error
 	getHaInfraDetailsfunc                        func() (*AutomateHAInfraDetails, *SSHConfig, error)
@@ -29,6 +34,7 @@ type MockNodeUtilsImpl struct {
 	saveConfigToBastionFunc                      func() error
 	syncConfigToAllNodesFunc                     func(unreachableNodes map[string][]string) error
 	restartPgNodesFunc                           func(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error
+	postPGCertRotateFunc                         func(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error
 }
 
 func (mnu *MockNodeUtilsImpl) executeAutomateClusterCtlCommandAsync(command string, args []string, helpDocs string) error {
@@ -122,3 +128,6 @@ func (mnu *MockNodeUtilsImpl) syncConfigToAllNodes(unreachableNodes map[string][
 func (mnu *MockNodeUtilsImpl) restartPgNodes(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error {
 	return mnu.restartPgNodesFunc(leaderNode, pgIps, infra, statusSummary)
 }
+func (mnu *MockNodeUtilsImpl) postPGCertRotate(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
+	return mnu.postPGCertRotateFunc(pgIps, sshconfig, fileUtils, log)
+}
diff --git a/components/automate-cli/cmd/chef-automate/restart.go b/components/automate-cli/cmd/chef-automate/restart.go
index 0ec2e9936..894cb42fe 100644
--- a/components/automate-cli/cmd/chef-automate/restart.go
+++ b/components/automate-cli/cmd/chef-automate/restart.go
@@ -13,6 +13,8 @@ import (
 	"github.com/chef/automate/components/automate-cli/pkg/status"
 	"github.com/chef/automate/components/automate-deployment/pkg/cli"
 	"github.com/chef/automate/components/automate-deployment/pkg/client"
+	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 )
 
 const (
@@ -81,7 +83,15 @@ func runRestartServices(cmd *cobra.Command, args []string, flags *RestartCmdFlag
 	if isA2HARBFileExist() {
 		nodeOpUtils := &NodeUtilsImpl{}
 		remoteExcecutor := NewRemoteCmdExecutorWithoutNodeMap(&SSHUtilImpl{}, cli.NewWriter(os.Stdout, os.Stderr, os.Stdin))
-		return runRestartFromBastion(flags, remoteExcecutor, nodeOpUtils, printRestartOutput)
+		infra, _, err := nodeOpUtils.getHaInfraDetails()
+		if err != nil {
+			return err
+		}
+		statusSummary, err := getStatusSummary(infra)
+		if err != nil {
+			return err
+		}
+		return runRestartFromBastion(flags, remoteExcecutor, nodeOpUtils, printRestartOutput, statusSummary)
 	}
 	connection, err := client.Connection(client.DefaultClientTimeout)
 	if err != nil {
@@ -110,7 +120,7 @@ func runRestartServices(cmd *cobra.Command, args []string, flags *RestartCmdFlag
 	return nil
 }
 
-func runRestartFromBastion(flags *RestartCmdFlags, rs RemoteCmdExecutor, nu NodeOpUtils, printRestartOutput func(map[string][]*CmdResult, string, *cli.Writer)) error {
+func runRestartFromBastion(flags *RestartCmdFlags, rs RemoteCmdExecutor, nu NodeOpUtils, printRestartOutput func(map[string][]*CmdResult, string, *cli.Writer), statusSummary StatusSummary) error {
 	infra, _, err := nu.getHaInfraDetails()
 	if err != nil {
 		return err
@@ -142,7 +152,7 @@ func runRestartFromBastion(flags *RestartCmdFlags, rs RemoteCmdExecutor, nu Node
 		return handleManagedServices(flags)
 	}
 
-	runRestartCmdForBackend(infra, flags, rs, restartCmdResults)
+	runRestartCmdForBackend(infra, flags, rs, restartCmdResults, nu, statusSummary)
 
 	return getChannelValue(restartCmdResults, printRestartOutput)
 }
@@ -162,11 +172,11 @@ func runRestartCmdForFrontEnd(infra *AutomateHAInfraDetails, flags *RestartCmdFl
 	}
 }
 
-func runRestartCmdForBackend(infra *AutomateHAInfraDetails, flags *RestartCmdFlags, rs RemoteCmdExecutor, restartCmdResults chan restartCmdResult) {
+func runRestartCmdForBackend(infra *AutomateHAInfraDetails, flags *RestartCmdFlags, rs RemoteCmdExecutor, restartCmdResults chan restartCmdResult, nu NodeOpUtils, statusSummary StatusSummary) {
 	flags.automate = false
 	flags.chefServer = false
 	if flags.postgresql {
-		restartOnGivenNode(flags, POSTGRESQL, infra, rs, restartCmdResults)
+		restartAndReloadPgConfig(restartCmdResults, nu, statusSummary)
 	} else {
 		restartCmdResults <- restartCmdResult{}
 	}
@@ -178,6 +188,63 @@ func runRestartCmdForBackend(infra *AutomateHAInfraDetails, flags *RestartCmdFla
 	}
 }
 
+func restartAndReloadPgConfig(restartCmdResults chan restartCmdResult, nu NodeOpUtils, statusSummary StatusSummary) {
+	infra, sshConfig, err := nu.getHaInfraDetails()
+	if err != nil {
+		restartCmdResults <- restartCmdResult{
+			err: err,
+		}
+	}
+	level := "info"
+	if globalOpts.debug {
+		level = "debug"
+	}
+
+	log, err := logger.NewLogger("text", level)
+	if err != nil {
+		restartCmdResults <- restartCmdResult{
+			err: err,
+		}
+	}
+	fileUtils := &fileutils.FileSystemUtils{}
+	sshConfig.timeout = DEFAULT_TIMEOUT
+
+	// restart pg nodes in a sequence of follower nodes first and then leader node
+	leader := getPGLeaderFunc(statusSummary)
+	err = nu.restartPgNodes(*leader, infra.Outputs.PostgresqlPrivateIps.Value, infra, statusSummary)
+	if err != nil {
+		restartCmdResults <- restartCmdResult{
+			err: err,
+		}
+	}
+	// restart done
+
+	// reloading the pg config to make sure all nodes of pg have correct config
+	err = nu.postPGCertRotate(infra.Outputs.PostgresqlPrivateIps.Value, *sshConfig, fileUtils, log)
+	if err != nil {
+		restartCmdResults <- restartCmdResult{
+			err: err,
+		}
+	}
+	cmdResult := []*CmdResult{}
+	for _, v := range infra.Outputs.PostgresqlPrivateIps.Value {
+		cmdResult = append(cmdResult, &CmdResult{
+			ScriptName: "restart and reload pg",
+			HostIP:     v,
+			Output:     "successfully restared and reloaded postgresql node",
+		})
+	}
+	restartCmdResults <- restartCmdResult{
+		cmdResult: map[string][]*CmdResult{
+			POSTGRESQL: cmdResult,
+		},
+		writer:   writer,
+		nodeType: POSTGRESQL,
+		err:      err,
+	}
+	// config reload done
+}
+
 func restartOnGivenNode(flags *RestartCmdFlags, nodeType string, infra *AutomateHAInfraDetails, rs RemoteCmdExecutor, restartCmdResults chan restartCmdResult) {
 	go func(flags RestartCmdFlags, restartCmdResults chan<- restartCmdResult) {
 		writer := cli.NewWriter(os.Stdout, os.Stderr, os.Stdin)
diff --git a/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice.go b/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice.go
index ac0d49e29..b0b83e134 100644
--- a/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice.go
+++ b/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice.go
@@ -33,7 +33,7 @@ func (pg *ExternalPostgresqlServiceImpl) GetPgConnection(req *models.ExternalPgR
 	pg.Req = req
 
 	//creating a temp file to copy the content of a rootcert into a file
-	rootcert, err := pg.fileUtils.CreateTempFile(req.PostgresqlRootCert, "root-cert")
+	rootcert, err := pg.fileUtils.CreateTempFile(req.PostgresqlRootCert, "root-cert", "")
 	if err != nil {
 		return nil, err
 	}
diff --git a/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice.go b/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice.go
index 40893e1c2..bda31b0c3 100644
--- a/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice.go
+++ b/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice.go
@@ -4,8 +4,8 @@ import (
 	"fmt"
 	"strings"
 
-	"github.com/chef/automate/components/automate-cli/pkg/verifyserver/models"
 	"github.com/chef/automate/components/automate-cli/pkg/verifyserver/constants"
+	"github.com/chef/automate/components/automate-cli/pkg/verifyserver/models"
 	"github.com/chef/automate/lib/io/fileutils"
 	"github.com/chef/automate/lib/logger"
 	"github.com/chef/automate/lib/sshutils"
@@ -34,7 +34,7 @@ func NewSshUserCheckService(logger logger.Logger, fileutils fileutils.FileUtils,
 func (ssu *SshUserServiceImpl) CheckSshUserDetails(req *models.SshUserChecksRequest) (*models.ChecksResponse, error) {
 	ssu.logger.Debugf("The Request value entered by the user ip: %v, port: %v, userName: %v ", req.Ip, req.Port, req.UserName)
 
-	filePath, err := ssu.FileUtils.CreateTempFile(req.PrivateKey, constants.PEM_FILE_NAME)
+	filePath, err := ssu.FileUtils.CreateTempFile(req.PrivateKey, constants.PEM_FILE_NAME, "")
 	if err != nil {
 		ssu.logger.Error("Error while creating the key file on the desired file path: ", err)
 		return nil, err
diff --git a/components/automate-platform-tools/cmd/secrets-helper/secrets-helper.go b/components/automate-platform-tools/cmd/secrets-helper/secrets-helper.go
index 2c5b02bd3..7ee798ca3 100644
--- a/components/automate-platform-tools/cmd/secrets-helper/secrets-helper.go
+++ b/components/automate-platform-tools/cmd/secrets-helper/secrets-helper.go
@@ -9,15 +9,14 @@
 // The current implementation uses a files on disk for
 // storage.
 //
-// KNOWN ISSUES
-//
-// - generate and insert are not safe for concurrent access to the
-//   same key. A basic check is in place to allow "idempotent"-ish
-//   operations for a single service, but if multiple services are
-//   generating the same key the last writer wins. However, we ARE
-//   concurrency safe for /different/ keys since those are stored in
-//   different files on disk.
+// # KNOWN ISSUES
 //
+//   - generate and insert are not safe for concurrent access to the
+//     same key. A basic check is in place to allow "idempotent"-ish
+//     operations for a single service, but if multiple services are
+//     generating the same key the last writer wins. However, we ARE
+//     concurrency safe for /different/ keys since those are stored in
+//     different files on disk.
 package main
 
 import (
@@ -45,9 +44,7 @@ import (
 
 var defaultWatchInterval = 15 * time.Second
 
-//
 // Option structs
-//
 type globalOptions struct {
 	// Enables debug logging output
 	debug bool
@@ -233,7 +230,6 @@ func newSecretsStore() (secrets.SecretStore, error) {
 	return secrets.NewDiskStore(globalOpts.dataDir, uid, gid), nil
 }
 
-//
 // Subcommand funcs
 //
 // NOTE(ssd) 2018-08-20: These top level functions assume that the
@@ -442,9 +438,7 @@ func execCommand(_ *cobra.Command, args []string) {
 		cmd.Stderr = os.Stderr
 		cmd.Stdout = os.Stdout
 		cmd.Stdin = os.Stdin
-		cmd.SysProcAttr = &syscall.SysProcAttr{
-			Pdeathsig: syscall.SIGTERM,
-		}
+		cmd.SysProcAttr = &syscall.SysProcAttr{}
 
 		logrus.WithFields(logrus.Fields{
 			"secrets_fd": readPipe.Fd(),
diff --git a/lib/io/fileutils/fileutils.go b/lib/io/fileutils/fileutils.go
index dcfb3e00e..69211a0fb 100644
--- a/lib/io/fileutils/fileutils.go
+++ b/lib/io/fileutils/fileutils.go
@@ -33,12 +33,13 @@ type FileUtils interface {
 	WriteToFile(filepath string, data []byte) error
 	ReadFile(filename string) ([]byte, error)
 	WriteFile(filepath string, data []byte, perm os.FileMode) error
-	CreateTempFile(content string, filename string) (string, error)
+	CreateTempFile(content string, filename string, dir string) (string, error)
 	DeleteFile(fileName string) error
 	Move(sourceFile string, destinationFile string) error
 	RemoveFirstLine(filePath string) error
 	GetFilePermission(filePath string) (int64, error)
 	Stat(name string) (os.FileInfo, error)
+	RemoveFile(filename string) error
 }
 
 type FileSystemUtils struct{}
@@ -74,8 +75,8 @@ func (fsu *FileSystemUtils) ReadFile(filename string) ([]byte, error) {
 func (fsu *FileSystemUtils) WriteFile(filepath string, data []byte, perm os.FileMode) error {
 	return WriteFile(filepath, data, perm)
 }
-func (fsu *FileSystemUtils) CreateTempFile(content string, filename string) (string, error) {
-	return CreateTempFile(content, filename)
+func (fsu *FileSystemUtils) CreateTempFile(content string, filename string, dir string) (string, error) {
+	return CreateTempFile(content, filename, dir)
 }
 func (fsu *FileSystemUtils) DeleteFile(filePath string) error {
 	return DeleteFile(filePath)
@@ -96,6 +97,10 @@ func (fsu *FileSystemUtils) Stat(name string) (os.FileInfo, error) {
 	return os.Stat(name)
 }
 
+func (fsu *FileSystemUtils) RemoveFile(filename string) error {
+	return os.Remove(filename)
+}
+
 // LogCLose closes the given io.Closer, logging any error.
 func LogClose(c io.Closer, log logrus.FieldLogger, msg string) {
 	if err := c.Close(); err != nil {
@@ -192,8 +197,8 @@ func WriteFile(filepath string, data []byte, perm os.FileMode) error {
 	return os.WriteFile(filepath, data, perm)
 }
 
-func CreateTempFile(content string, filename string) (string, error) {
-	tempFile, err := os.CreateTemp("", filename)
+func CreateTempFile(content string, filename string, dir string) (string, error) {
+	tempFile, err := os.CreateTemp(dir, filename)
 	if err != nil {
 		return "", errors.Wrap(err, "file creation failed ")
 	}
diff --git a/lib/io/fileutils/mockFileUtils.go b/lib/io/fileutils/mockFileUtils.go
index f70516a27..a667f4e02 100644
--- a/lib/io/fileutils/mockFileUtils.go
+++ b/lib/io/fileutils/mockFileUtils.go
@@ -16,12 +16,13 @@ type MockFileSystemUtils struct {
 	WriteToFileFunc            func(filepath string, data []byte) error
 	ReadFileFunc               func(filepath string) ([]byte, error)
 	WriteFileFunc              func(filepath string, data []byte, perm os.FileMode) error
-	CreateTempFileFunc         func(content string, filename string) (string, error)
+	CreateTempFileFunc         func(content string, filename string, dir string) (string, error)
 	DeleteTempFileFunc         func(tempFile string) error
 	MoveFunc                   func(sourceFile string, destinationFile string) error
 	RemoveFirstLineFunc        func(filePath string) error
 	GetFilePermissionFunc      func(filePath string) (int64, error)
 	StatFunc                   func(name string) (os.FileInfo, error)
+	RemoveFileFunc             func(filename string) error
 }
 
 func (fsu *MockFileSystemUtils) PathExists(path string) (bool, error) {
@@ -51,8 +52,8 @@ func (fsu *MockFileSystemUtils) ReadFile(filepath string) ([]byte, error) {
 func (fsu *MockFileSystemUtils) WriteFile(filepath string, data []byte, perm os.FileMode) error {
 	return fsu.WriteFileFunc(filepath, data, perm)
 }
-func (fsu *MockFileSystemUtils) CreateTempFile(content string, filename string) (string, error) {
-	return fsu.CreateTempFileFunc(content, filename)
+func (fsu *MockFileSystemUtils) CreateTempFile(content string, filename string, dir string) (string, error) {
+	return fsu.CreateTempFileFunc(content, filename, dir)
 }
 func (fsu *MockFileSystemUtils) DeleteFile(tempFile string) error {
 	return fsu.DeleteTempFileFunc(tempFile)
@@ -69,6 +70,9 @@ func (fsu *MockFileSystemUtils) GetFilePermission(filePath string) (int64, error
 func (fsu *MockFileSystemUtils) Stat(name string) (os.FileInfo, error) {
 	return fsu.StatFunc(name)
 }
+func (fsu *MockFileSystemUtils) RemoveFile(name string) error {
+	return fsu.RemoveFileFunc(name)
+}
 
 type MockFileInfo struct {
 	NameFunc    func() string      // base name of the file


Test patch:
diff --git a/components/automate-cli/cmd/chef-automate/certRotate_test.go b/components/automate-cli/cmd/chef-automate/certRotate_test.go
index 086afee2e..12a05f3e5 100644
--- a/components/automate-cli/cmd/chef-automate/certRotate_test.go
+++ b/components/automate-cli/cmd/chef-automate/certRotate_test.go
@@ -3114,19 +3114,31 @@ func TestCertRotateFromTemplate(t *testing.T) {
 
 	for _, testCase := range testCases {
 		t.Run(testCase.description, func(t *testing.T) {
-			c := certRotateFlow{fileUtils: &fileutils.MockFileSystemUtils{
-				ReadFileFunc: func(filepath string) ([]byte, error) {
-					if strings.Contains(filepath, "a2ha_manifest.auto.tfvars") {
-						return []byte(`elasticsidecar_pkg_ident = "chef/automate-ha-elasticsidecar/0.1.0/20240725174312"
+			c := certRotateFlow{
+				nodeUtils: &MockNodeUtilsImpl{
+					postPGCertRotateFunc: func(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
+						return nil
+					},
+				},
+				fileUtils: &fileutils.MockFileSystemUtils{
+					ReadFileFunc: func(filepath string) ([]byte, error) {
+						if strings.Contains(filepath, "a2ha_manifest.auto.tfvars") {
+							return []byte(`elasticsidecar_pkg_ident = "chef/automate-ha-elasticsidecar/0.1.0/20240725174312"
 	proxy_pkg_ident = "chef/automate-ha-haproxy/2.2.14/20240725171322"
 	opensearch_pkg_ident = "chef/automate-ha-opensearch/1.3.14/20240725173732"
 	pgleaderchk_pkg_ident = "chef/automate-ha-pgleaderchk/0.1.0/20240725172920"
 	postgresql_pkg_ident = "chef/automate-ha-postgresql/13.14.0/20240725171322"`), nil
-					}
-					fu := fileutils.FileSystemUtils{}
-					return fu.ReadFile(filepath)
+						}
+						fu := fileutils.FileSystemUtils{}
+						return fu.ReadFile(filepath)
+					},
+					CreateTempFileFunc: func(content, filename, dir string) (string, error) {
+						return filename, nil
+					},
+					RemoveFileFunc: func(filename string) error {
+						return nil
+					},
 				},
-			},
 				sshUtil: testCase.MockSSHUtil,
 				writer:  getMockWriterImpl(), log: log}
 			output := c.certRotateFromTemplate(testCase.certFileName, testCase.sshutil, testCase.inf, testCase.currentCertsInfo, testCase.statusSummary, false, 0, &certRotateFlags{})
diff --git a/components/automate-cli/cmd/chef-automate/ha_node_delete_aws_test.go b/components/automate-cli/cmd/chef-automate/ha_node_delete_aws_test.go
index 57e5ee11f..9aa233df7 100644
--- a/components/automate-cli/cmd/chef-automate/ha_node_delete_aws_test.go
+++ b/components/automate-cli/cmd/chef-automate/ha_node_delete_aws_test.go
@@ -5,6 +5,7 @@ import (
 	"testing"
 
 	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 	"github.com/chef/automate/lib/majorupgrade_utils"
 	"github.com/pkg/errors"
 	"github.com/stretchr/testify/assert"
@@ -739,6 +740,9 @@ func TestDeletenodeAWSExecuteNoError(t *testing.T) {
 		restartPgNodesFunc: func(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error {
 			return nil
 		},
+		postPGCertRotateFunc: func(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
+			return nil
+		},
 	}
 	flagsArr := []AddDeleteNodeHACmdFlags{
 		{
@@ -770,6 +774,15 @@ func TestDeletenodeAWSExecuteNoError(t *testing.T) {
 			CONFIG_TOML_PATH_AWS,
 			&fileutils.MockFileSystemUtils{},
 			&MockSSHUtilsImpl{
+				getSSHConfigFunc: func() *SSHConfig {
+					return &SSHConfig{
+						sshUser:    "ubuntu",
+						sshPort:    "22",
+						sshKeyFile: "/rt.pem",
+						hostIP:     "12.12.12.12",
+						timeout:    30,
+					}
+				},
 				connectAndExecuteCommandOnRemoteFunc: func(remoteCommands string, spinner bool) (string, error) {
 					return "", nil
 				},
diff --git a/components/automate-cli/cmd/chef-automate/ha_node_operations_utils_test.go b/components/automate-cli/cmd/chef-automate/ha_node_operations_utils_test.go
index bd2eafa21..9631755a7 100644
--- a/components/automate-cli/cmd/chef-automate/ha_node_operations_utils_test.go
+++ b/components/automate-cli/cmd/chef-automate/ha_node_operations_utils_test.go
@@ -907,7 +907,7 @@ func TestPrePatchForFrontendNodes(t *testing.T) {
 			[[load_balancer.v1.sys.frontend_tls]]
 			cert = ""`
 
-	filePath, err := fileutils.CreateTempFile(tomlFileContent, AUTOMATE_TOML)
+	filePath, err := fileutils.CreateTempFile(tomlFileContent, AUTOMATE_TOML, "")
 	assert.NoError(t, err)
 	defer fileutils.DeleteFile(filePath)
 
@@ -930,7 +930,7 @@ func TestPrePatchForFrontendNodes(t *testing.T) {
 	t.Run("with invalid toml file content", func(t *testing.T) {
 		tomlFileContent := `
 	[deploy`
-		filePath, err := fileutils.CreateTempFile(tomlFileContent, AUTOMATE_TOML)
+		filePath, err := fileutils.CreateTempFile(tomlFileContent, AUTOMATE_TOML, "")
 		assert.NoError(t, err)
 		cmpInput := &CmdInputs{
 			InputFiles: []string{AUTOMATE_TOML},
@@ -946,7 +946,7 @@ func TestPrePatchForOsNodes(t *testing.T) {
 	tomlFileContent := `[cluster]
 	max_shards_per_node = "2000"`
 
-	filePath, err := fileutils.CreateTempFile(tomlFileContent, OPENSEARCH_TOML)
+	filePath, err := fileutils.CreateTempFile(tomlFileContent, OPENSEARCH_TOML, "")
 	assert.NoError(t, err)
 	defer fileutils.DeleteFile(filePath)
 
@@ -961,7 +961,7 @@ func TestPrePatchForOsNodes(t *testing.T) {
 	t.Run("with invalid toml file content", func(t *testing.T) {
 		tomlFileContent := `
 	[cluster`
-		filePath, err := fileutils.CreateTempFile(tomlFileContent, OPENSEARCH_TOML)
+		filePath, err := fileutils.CreateTempFile(tomlFileContent, OPENSEARCH_TOML, "")
 		assert.NoError(t, err)
 		cmpInput := &CmdInputs{
 			InputFiles: []string{OPENSEARCH_TOML},
@@ -1018,7 +1018,7 @@ func TestParseAndMoveConfigFileToWorkspaceDir(t *testing.T) {
 			cert = ""
 `
 
-	filePath, err := fileutils.CreateTempFile(tomlFileContent, AUTOMATE_TOML)
+	filePath, err := fileutils.CreateTempFile(tomlFileContent, AUTOMATE_TOML, "")
 	assert.NoError(t, err)
 	defer fileutils.DeleteFile(filePath)
 
diff --git a/components/automate-cli/cmd/chef-automate/restart_test.go b/components/automate-cli/cmd/chef-automate/restart_test.go
index 75aef54bc..1586ff6f6 100644
--- a/components/automate-cli/cmd/chef-automate/restart_test.go
+++ b/components/automate-cli/cmd/chef-automate/restart_test.go
@@ -5,6 +5,8 @@ import (
 
 	"github.com/chef/automate/components/automate-cli/pkg/status"
 	"github.com/chef/automate/components/automate-deployment/pkg/cli"
+	"github.com/chef/automate/lib/io/fileutils"
+	"github.com/chef/automate/lib/logger"
 	"github.com/pkg/errors"
 	"github.com/stretchr/testify/assert"
 )
@@ -98,6 +100,23 @@ func TestRunRestartFromBastion(t *testing.T) {
 		errorWant            error
 	}
 	printRestartOutput := func(m map[string][]*CmdResult, s string, w *cli.Writer) {}
+	mockNodeUtils := &MockNodeUtilsImpl{
+		getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
+			return getMockInfra(), &SSHConfig{}, nil
+		},
+		isManagedServicesOnFunc: func() bool {
+			return false
+		},
+		postPGCertRotateFunc: func(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
+			return nil
+		},
+		getConfigPullerFunc: func(sshUtil *SSHUtil) (PullConfigs, error) {
+			return &MockPullConfigs{}, nil
+		},
+		restartPgNodesFunc: func(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error {
+			return nil
+		},
+	}
 	testCases := []testCase{
 		{
 			description: "Error when wait timeout is less than default timeout",
@@ -106,14 +125,7 @@ func TestRunRestartFromBastion(t *testing.T) {
 				restartCmdFlags.timeout = 120
 				return restartCmdFlags
 			}(),
-			mockRestartCmdHelper: &MockNodeUtilsImpl{
-				getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
-					return nil, &SSHConfig{}, nil
-				},
-				isManagedServicesOnFunc: func() bool {
-					return false
-				},
-			},
+			mockRestartCmdHelper: mockNodeUtils,
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
 					return map[string][]*CmdResult{}, nil
@@ -128,14 +140,7 @@ func TestRunRestartFromBastion(t *testing.T) {
 				restartCmdFlags.node = "1"
 				return restartCmdFlags
 			}(),
-			mockRestartCmdHelper: &MockNodeUtilsImpl{
-				getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
-					return nil, &SSHConfig{}, nil
-				},
-				isManagedServicesOnFunc: func() bool {
-					return false
-				},
-			},
+			mockRestartCmdHelper: mockNodeUtils,
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
 					return map[string][]*CmdResult{}, nil
@@ -156,6 +161,15 @@ func TestRunRestartFromBastion(t *testing.T) {
 				isManagedServicesOnFunc: func() bool {
 					return false
 				},
+				postPGCertRotateFunc: func(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
+					return nil
+				},
+				getConfigPullerFunc: func(sshUtil *SSHUtil) (PullConfigs, error) {
+					return &MockPullConfigs{}, nil
+				},
+				restartPgNodesFunc: func(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error {
+					return nil
+				},
 			},
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
@@ -170,14 +184,7 @@ func TestRunRestartFromBastion(t *testing.T) {
 				restartCmdFlags := newDefaultRestartCmdFlag()
 				return restartCmdFlags
 			}(),
-			mockRestartCmdHelper: &MockNodeUtilsImpl{
-				getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
-					return nil, &SSHConfig{}, nil
-				},
-				isManagedServicesOnFunc: func() bool {
-					return false
-				},
-			},
+			mockRestartCmdHelper: mockNodeUtils,
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
 					return map[string][]*CmdResult{}, nil
@@ -192,17 +199,10 @@ func TestRunRestartFromBastion(t *testing.T) {
 				restartCmdFlags := newDefaultRestartCmdFlag()
 				return restartCmdFlags
 			}(),
-			mockRestartCmdHelper: &MockNodeUtilsImpl{
-				getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
-					return nil, &SSHConfig{}, nil
-				},
-				isManagedServicesOnFunc: func() bool {
-					return false
-				},
-			},
+			mockRestartCmdHelper: mockNodeUtils,
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
-					return map[string][]*CmdResult{}, nil
+					return map[string][]*CmdResult{}, errors.New("Some error occured while remote execution")
 				},
 				SetWriterFunc: func(cli *cli.Writer) {},
 			},
@@ -214,14 +214,7 @@ func TestRunRestartFromBastion(t *testing.T) {
 				restartCmdFlags := newDefaultRestartCmdFlag()
 				return restartCmdFlags
 			}(),
-			mockRestartCmdHelper: &MockNodeUtilsImpl{
-				getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
-					return nil, &SSHConfig{}, nil
-				},
-				isManagedServicesOnFunc: func() bool {
-					return false
-				},
-			},
+			mockRestartCmdHelper: mockNodeUtils,
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
 					return map[string][]*CmdResult{}, nil
@@ -239,11 +232,20 @@ func TestRunRestartFromBastion(t *testing.T) {
 			}(),
 			mockRestartCmdHelper: &MockNodeUtilsImpl{
 				getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
-					return nil, &SSHConfig{}, nil
+					return getMockInfra(), &SSHConfig{}, nil
 				},
 				isManagedServicesOnFunc: func() bool {
 					return true
 				},
+				postPGCertRotateFunc: func(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
+					return nil
+				},
+				getConfigPullerFunc: func(sshUtil *SSHUtil) (PullConfigs, error) {
+					return &MockPullConfigs{}, nil
+				},
+				restartPgNodesFunc: func(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error {
+					return nil
+				},
 			},
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
@@ -262,11 +264,20 @@ func TestRunRestartFromBastion(t *testing.T) {
 			}(),
 			mockRestartCmdHelper: &MockNodeUtilsImpl{
 				getHaInfraDetailsfunc: func() (*AutomateHAInfraDetails, *SSHConfig, error) {
-					return nil, &SSHConfig{}, nil
+					return getMockInfra(), &SSHConfig{}, nil
 				},
 				isManagedServicesOnFunc: func() bool {
 					return true
 				},
+				postPGCertRotateFunc: func(pgIps []string, sshconfig SSHConfig, fileUtils fileutils.FileUtils, log logger.Logger) error {
+					return nil
+				},
+				getConfigPullerFunc: func(sshUtil *SSHUtil) (PullConfigs, error) {
+					return &MockPullConfigs{}, nil
+				},
+				restartPgNodesFunc: func(leaderNode NodeIpHealth, pgIps []string, infra *AutomateHAInfraDetails, statusSummary StatusSummary) error {
+					return nil
+				},
 			},
 			mockRemoteCmdExec: &MockRemoteCmdExecutor{
 				ExecuteWithNodeMapFunc: func(nodemap *NodeTypeAndCmd) (map[string][]*CmdResult, error) {
@@ -280,9 +291,20 @@ func TestRunRestartFromBastion(t *testing.T) {
 
 	for _, testCase := range testCases {
 		t.Run(testCase.description, func(t *testing.T) {
-			err := runRestartFromBastion(testCase.flags, testCase.mockRemoteCmdExec, testCase.mockRestartCmdHelper, printRestartOutput)
-			if err != nil {
-				assert.EqualError(t, testCase.errorWant, err.Error())
+			getAutomateHAInfraDetailsFunc = func() (*AutomateHAInfraDetails, error) {
+				infra := &AutomateHAInfraDetails{}
+				infra.Outputs.PostgresqlPrivateIps.Value = []string{ValidIP7, ValidIP8, ValidIP9}
+				return infra, nil
+			}
+			getPGLeaderFunc = func(StatusSummary) *NodeIpHealth {
+				return &NodeIpHealth{
+					IP:     ValidIP7,
+					Health: "OK",
+				}
+			}
+			err := runRestartFromBastion(testCase.flags, testCase.mockRemoteCmdExec, testCase.mockRestartCmdHelper, printRestartOutput, getMockStatusSummary())
+			if testCase.errorWant != nil {
+				assert.EqualError(t, err, testCase.errorWant.Error())
 			} else {
 				assert.Nil(t, err)
 			}
diff --git a/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice_test.go b/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice_test.go
index b54a39ba4..11b488a7f 100644
--- a/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice_test.go
+++ b/components/automate-cli/pkg/verifyserver/services/externalpostgresqlservice/externalpostgresqlservice_test.go
@@ -32,7 +32,7 @@ func TestExternalPostgresqlService(t *testing.T) {
 			return nil
 		},
 	}, &fileutils.MockFileSystemUtils{
-		CreateTempFileFunc: func(content string, filename string) (string, error) {
+		CreateTempFileFunc: func(content string, filename string, dir string) (string, error) {
 			return "", nil
 		},
 		DeleteTempFileFunc: func(tempFile string) error {
@@ -69,7 +69,7 @@ func TestExternalPostgresqlServiceFailure(t *testing.T) {
 			return errors.New("")
 		},
 	}, &fileutils.MockFileSystemUtils{
-		CreateTempFileFunc: func(content string, filename string) (string, error) {
+		CreateTempFileFunc: func(content string, filename string, dir string) (string, error) {
 			return "", nil
 		},
 		DeleteTempFileFunc: func(tempFile string) error {
diff --git a/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice_test.go b/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice_test.go
index 3014fe818..16124c994 100644
--- a/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice_test.go
+++ b/components/automate-cli/pkg/verifyserver/services/sshusercheckservice/sshusercheckservice_test.go
@@ -52,7 +52,7 @@ func TestCheckSshUserDetails(t *testing.T) {
 					SudoPassword: sudoPassword,
 				},
 				MockFileUtils: &fileutils.MockFileSystemUtils{
-					CreateTempFileFunc: func(content, filename string) (string, error) {
+					CreateTempFileFunc: func(content, filename string, dir string) (string, error) {
 						return "", nil
 					},
 					DeleteTempFileFunc: func(tempFile string) error {
@@ -97,7 +97,7 @@ func TestCheckSshUserDetails(t *testing.T) {
 					SudoPassword: sudoPassword,
 				},
 				MockFileUtils: &fileutils.MockFileSystemUtils{
-					CreateTempFileFunc: func(content, filename string) (string, error) {
+					CreateTempFileFunc: func(content, filename string, dir string) (string, error) {
 						return "", errors.New("file creation failed ")
 					},
 					DeleteTempFileFunc: func(tempFile string) error {
diff --git a/lib/io/fileutils/fileutils_test.go b/lib/io/fileutils/fileutils_test.go
index 9040d1fdf..a309e25d5 100644
--- a/lib/io/fileutils/fileutils_test.go
+++ b/lib/io/fileutils/fileutils_test.go
@@ -58,13 +58,13 @@ func TestCreateTempFile(t *testing.T) {
 	content := "abc"
 	filename := "file-name"
 	t.Run("It creates the file", func(t *testing.T) {
-		res1, err := fileutils.CreateTempFile(content, filename)
+		res1, err := fileutils.CreateTempFile(content, filename, "")
 		require.NoError(t, err)
-		res2, err := fileutils.CreateTempFile(content, filename)
+		res2, err := fileutils.CreateTempFile(content, filename, "")
 		require.NoError(t, err)
-		res3, err := fileutils.CreateTempFile(content, filename)
+		res3, err := fileutils.CreateTempFile(content, filename, "")
 		require.NoError(t, err)
-		res4, err := fileutils.CreateTempFile(content, filename)
+		res4, err := fileutils.CreateTempFile(content, filename, "")
 		require.NoError(t, err)
 		assert.Contains(t, res1, "file-name")
 		assert.Contains(t, res2, "file-name")
@@ -93,7 +93,7 @@ func TestMove(t *testing.T) {
 	defer os.RemoveAll(destinationDir)
 
 	t.Run("Move a file to new directory", func(t *testing.T) {
-		srcFile, err := fileutils.CreateTempFile(content, filename)
+		srcFile, err := fileutils.CreateTempFile(content, filename, "")
 		assert.Contains(t, srcFile, "file-name")
 		require.NoError(t, err)
 		defer fileutils.DeleteFile(srcFile)
@@ -107,7 +107,7 @@ func TestMove(t *testing.T) {
 	})
 
 	t.Run("Move a file to a directory and overwrite the existing file", func(t *testing.T) {
-		srcFile, err := fileutils.CreateTempFile(content, filename)
+		srcFile, err := fileutils.CreateTempFile(content, filename, "")
 		assert.Contains(t, srcFile, "file-name")
 		require.NoError(t, err)
 		defer fileutils.DeleteFile(srcFile)
@@ -120,7 +120,7 @@ func TestMove(t *testing.T) {
 	})
 
 	t.Run("Invalid destinationfile", func(t *testing.T) {
-		srcFile, err := fileutils.CreateTempFile(content, filename)
+		srcFile, err := fileutils.CreateTempFile(content, filename, "")
 		assert.Contains(t, srcFile, "file-name")
 		require.NoError(t, err)
 		defer fileutils.DeleteFile(srcFile)
@@ -149,7 +149,7 @@ func TestRemoveFirstLine(t *testing.T) {
 	os.Setenv("TMPDIR", fileutils.HAB_TMP_DIR)
 
 	t.Run("Remove first line", func(t *testing.T) {
-		res, err := fileutils.CreateTempFile(content, filename)
+		res, err := fileutils.CreateTempFile(content, filename, "")
 		assert.Contains(t, res, "file-name")
 		require.NoError(t, err)
 		err = fileutils.RemoveFirstLine(res)