How does Ansible find group_vars when working with Terraform

Viewed 135

I'm setting up a project using terraform and Ansible. After Terraform creates all the needed resources, I need to provision the servers using Ansible, where I am using the following:

# provisioner "local-exec" {
#     environment = {
#       ANSIBLE_SSH_RETRIES       = "30"
#       ANSIBLE_HOST_KEY_CHECKING = "False"
#     }
#     command = "ansible-playbook ${var.ec2_ansible_playbook} --extra-vars env_name=${var.env} -u ubuntu -i ${aws_eip.main.0.public_ip},"
#   }

Ansible fails to find my group_vars, How do I point Ansible to the correct path where group_vars are located? Previously, I was only using Ansible and I would run something like

ansible-playbook provision.yml -i inventory/prod/hosts

Ansible wouldn't have any problems finding group_vars since they were sitting at the same location as the hosts. Any help is appreciated.

1 Answers

You can specify the working-dir like mentioned in the documentation

I think per default it uses the module directory as working directory.

Related