--- - connection: local gather_facts: false hosts: localhost tasks: - ec2: count: 3 image: ami-0cca6df87334a74bd instance_tags: type: webinar system: example third_tag: 3 instance_type: t2.micro key_name: webinar wait: true name: "create machine" register: ec2 - name: run ssh-keyscan to add keys to known_hosts local_action: shell ssh-keyscan {{ item.public_ip }} >> ~/.ssh/known_hosts with_items: "{{ ec2.instances }}"