I’m trying to call an ansible playbook via terrafrom remote-exec
I’m running into the following error
Error: remote-exec provisioner error
│
│ with null_resource.remote-exec-test,
│ on pb_rm.tf line 26, in resource "null_resource" "remote-exec-test":
│ 26: provisioner "remote-exec" {
│
│ timeout - last error: dial tcp 192.168.10.202:22: i/o timeout
My terraform and ansible VMs are on the same ESXi host and on the same vSwitch. Comms are fine, can ping each other etc… and I can ssh from terraform
to ansible
user@terraform:~/config_deploy_del_rm_test$ ssh 192.168.10.202
user@192.168.10.202's password:
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-80-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sat 07 Aug 2021 10:03:06 PM UTC
System load: 0.0 Processes: 225
Usage of /: 18.5% of 38.63GB Users logged in: 1
Memory usage: 5% IPv4 address for ens160: 192.168.10.202
Swap usage: 0%
88 updates can be installed immediately.
1 of these updates is a security update.
To see these additional updates run: apt list --upgradable
Last login: Sat Aug 7 21:52:55 2021 from 192.168.10.211
user@ansible:~$
Files
pb_rm.tf
resource "null_resource" "remote-exec-test" {
provisioner "remote-exec" {
inline = [
"ansible-playbook /home/user/config_deploy_del_rm_test/hw.yml",
"echo Done!",
]
}
connection {
type = "ssh"
user = "user"
password = "${var.password}"
host = "${var.host}"
}
}
variables.tf
variable "password"{
type = string
default = "password"
}
variable "host"{
type = string
default = "192.168.10.202"
}