Use Ansible ec2_remote_facts to add_host, and connect to newly added host
Clash Royale CLAN TAG #URR8PPP Use Ansible ec2_remote_facts to add_host, and connect to newly added host I have a newly created ec2 instance. I want to query AWS using Ansible's ec2_remote_facts to find that host's ip address, add it as a host, and connect to it in the next step of the playbook. ec2_remote_facts Here's what I have so far - - hosts: localhost tasks: - ec2_remote_facts: region: us-east-1 filters: image_id: ami-8b070ff4 register: ec2 - add_host: hostname: new_instance name: "{{ ec2.instances[0].private_ip_address }}" ansible_ssh_user: ubuntu ansible_ssh_private_key_file: ~/.ssh/my_key - hosts: new_instance tasks: - shell: 'echo $HOSTNAME' register: results - debug: var=results.stdout But I'm getting this error - "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname new_instance: nodename nor servname provided,...