terraform ansible - ghdrako/doc_snipets GitHub Wiki

Terraform provider for Ansible
Ansible provider for Terraform and collection
Implementing the Ansible Provisioner
resource "null_resource" "ansible_provisioner" {
  provisioner "local-exec" {
    command = "ansible-playbook -i ${self.private_ip}, playbook.yml"
    working_dir = "${path.module}/ansible"
# Assuming your Ansible playbook is in a folder called 'ansible' 
# within your Terraform module.
  }
}

The null_resource resource is a resource that does nothing but acts as a trigger, while the local-exec resource allows running local shell commands.