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…
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)- A3% (1)
- B3% (1)
- C5% (2)
- D89% (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
Community Discussion
No community discussion yet for this question.