create.yml 666 B

123456789101112131415161718192021222324252627282930
  1. ---
  2. -
  3. connection: local
  4. gather_facts: false
  5. hosts: localhost
  6. tasks:
  7. -
  8. ec2:
  9. count: 4
  10. image: ami-0cca6df87334a74bd
  11. instance_tags:
  12. type: webinar
  13. system: wordpress
  14. instance_type: t2.micro
  15. key_name: webinar
  16. wait: true
  17. name: "create machine"
  18. register: ec2
  19. -
  20. name: run ssh-keyscan to add keys to known_hosts
  21. shell: ssh-keyscan {{ item.public_ip }} >> /home/ubuntu/.ssh/known_hosts
  22. with_items: "{{ ec2.instances }}"
  23. -
  24. name: Print ips
  25. debug:
  26. msg: "{{ item.public_ip }}"
  27. with_items: "{{ ec2.instances }}"