On 13.10.21 13:51, Anirban Das wrote:
I have created aws ec2 instances through Terraform, so that time I have 
mentioned key name for ec2 launching. But yes didn't mention ansible private 
key in terraform script. So in the provisioner bock I put ansible playbook 
command with private-key path. What else do I need to do??

you can check below terraform script and please guide me.
=========================================

# Creating 3 EC2 Instances:

resource "aws_instance" "instance" {
   count           = length(aws_subnet.public_subnet.*.id)
   ami             = var.ami_id
   instance_type   = var.instance_type
   subnet_id       = element(aws_subnet.public_subnet.*.id, count.index)
   security_groups = [aws_security_group.sg.id, ]
   key_name        = "Keypair-01"

1. Confirm that the ssh key mentioned in "Keypair-01" is the one in your 
ssh-agent locally.
2. Confirm that your local user exists on the remote host, and has the ssh-key 
in the authorized_keys file.
3. Confirm that you can do "ssh -i /path/to/private/key AWS_HOST" and can log 
in without any problems.
4. See if you can run 'ansible AWS_HOST -m ping' and get a response.

These can provide clues to what is wrong.

--
https://blog.sandipb.net
https://twitter.com/sandipb

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/292b4912-97d4-d016-740c-cd39114f3356%40showmethesource.org.

Reply via email to