Use generated keypair for broadcast side-car
This commit is contained in:
parent
6bb0264045
commit
8cc7742d89
1 changed files with 15 additions and 2 deletions
17
broadcast.tf
17
broadcast.tf
|
|
@ -2,11 +2,24 @@ resource "aws_instance" "broadcast" {
|
|||
count = var.broadcast_enabled ? 1 : 0
|
||||
ami = "${data.aws_ami.image.id}"
|
||||
instance_type = "t3.medium"
|
||||
key_name = "jamulus"
|
||||
key_name = "${aws_key_pair.generated_key.key_name}"
|
||||
security_groups = [aws_security_group.ssh.name, aws_security_group.broadcast.name, aws_security_group.node-exporter.name] # Add your own IP to this group
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "sleep 30 && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u ubuntu -i '${self.public_ip},' --private-key ${"${path.module}/jamulus.pem"} broadcast-install.yml"
|
||||
command = <<-EOT
|
||||
echo '${tls_private_key.jamulus.private_key_openssh}' > ${aws_key_pair.generated_key.key_name} &&
|
||||
chmod 600 ${aws_key_pair.generated_key.key_name} &&
|
||||
sleep 30
|
||||
EOT
|
||||
}
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = <<-EOT
|
||||
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u ubuntu \
|
||||
-i '${self.public_ip},' \
|
||||
--private-key "${path.module}/${aws_key_pair.generated_key.key_name}" \
|
||||
broadcast-install.yml --extra-vars 'ec2_id=${self.id}'
|
||||
EOT
|
||||
}
|
||||
|
||||
tags = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue