Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a quiet mode for local-exec #32097

Closed
staranto opened this issue Oct 27, 2022 · 3 comments · Fixed by #32116
Closed

Provide a quiet mode for local-exec #32097

staranto opened this issue Oct 27, 2022 · 3 comments · Fixed by #32116
Labels
enhancement new new issue not yet triaged

Comments

@staranto
Copy link

staranto commented Oct 27, 2022

Terraform Version

Terraform v1.3.3                                                                                                                
on linux_amd64                                                                                                                  
+ provider registry.terraform.io/hashicorp/null v3.2.0

Use Cases

I find the echoing of the command that local-exec will execute to be entirely too verbose. The output from even relatively simple examples can be hard to parse. Medium- to high-complexity examples are overwhelming.

locals {
  test = {
    name = "Spacely Space Sprockets"
    competitor = "Cogswell Cogs"
  }
}

resource "null_resource" "test" {
  provisioner "local-exec" {
    command = <<CMD
      echo ${jsonencode(local.test)}
    CMD
  }
}

Produces this output --

Plan: 1 to add, 0 to change, 0 to destroy.
null_resource.test: Creating...
null_resource.test: Provisioning with 'local-exec'...
null_resource.test (local-exec):Executing: ["/bin/sh" "-c" "      echo {\"competitor\":\"Cogswell Cogs\",\"name\":\"Spacely Space Sprockets\"}\n"]
null_resource.test (local-exec):{competitor:Cogswell Cogs,name:Spacely Space Sprockets}
null_resource.test: Creation complete after 0s [id=5577006791947779410]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

The "Executing:" output is completely unnecessary.

Attempted Solutions

None. I don't see a way to suppress this.

Proposal

Provide a quiet parameter to local-exec. By default it is false indicating that local-exec should output the command about to be executed (i.e. the behavior remains as it is today). If it is true, the Executing: ... output will be supressed.

resource "null_resource" "test" {
  provisioner "local-exec" {
    quiet = true
    command = <<CMD
      echo ${jsonencode(local.test)}
    CMD
  }
}

Produces this output --

Plan: 1 to add, 0 to change, 0 to destroy.
null_resource.test: Creating...
null_resource.test: Provisioning with 'local-exec'...
null_resource.test (local-exec):{competitor:Cogswell Cogs,name:Spacely Space Sprockets}
null_resource.test: Creation complete after 0s [id=5577006791947779410]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

References

No response

@staranto staranto added enhancement new new issue not yet triaged labels Oct 27, 2022
@staranto
Copy link
Author

Or, alternative output for Executing line, something like --

null_resource.test (local-exec):Executing: Suppressed by quiet=true

@crw
Copy link
Collaborator

crw commented Nov 4, 2022

Thanks for this feature request!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants