-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you automatically populate hosts file with ip of created nodes by terraform? #1
Comments
This can be achieved with the terraform "local_exec" plugin like this taking advantage of the resource "null_resource" "ansible-provision" {
depends_on = ["aws_instance.ec2-master"]
##Create Masters Inventory
provisioner "local-exec" {
command = "echo \"[ec2-master]\" > ansible/inventories/iv1"
}
provisioner "local-exec" {
command = "echo \"\n${format("%s ansible_ssh_host=%s", aws_instance.ec2-master.tags.Name, aws_instance.ec2-master.public_ip)}\" >> ansible/inventories/iv&"
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doing this manually is very counter-productive every time. What are the variants to implement this?
The text was updated successfully, but these errors were encountered: