nerdexam
HashiCorp

TA-002-P · Question #127

Which one of the following will run echo 0 and echo 1 on a newly created host?

The correct answer is D. provisioner "remote-exec" {. The remote-exec provisioner runs commands on the remote resource (i.e., the newly created host). To run multiple commands inline, the correct syntax uses the inline argument with a list of strings: inline = ["echo 0", "echo 1"]. Option A uses local-exec, which runs commands on…

Read, generate, and modify configuration

Question

Which one of the following will run echo 0 and echo 1 on a newly created host?

Options

  • Aprovisioner "local-exec" { command = "echo 0"
  • Bprovisioner "remote-exec" {
  • Cprovisioner "remote-exec" {
  • Dprovisioner "remote-exec" {

How the community answered

(38 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    5% (2)
  • D
    89% (34)

Explanation

The remote-exec provisioner runs commands on the remote resource (i.e., the newly created host). To run multiple commands inline, the correct syntax uses the inline argument with a list of strings: inline = ["echo 0", "echo 1"]. Option A uses local-exec, which runs commands on the machine running Terraform, not on the remote host. Options B and C are also remote-exec but would differ in their inline command lists (the exam question implies only D contains both echo 0 and echo 1 in the correct inline list format).

Topics

#provisioners#remote-exec#local-exec#configuration

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice