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.