create.yml 606 B

1234567891011121314151617181920212223
  1. ---
  2. -
  3. connection: local
  4. gather_facts: false
  5. hosts: localhost
  6. tasks:
  7. -
  8. ec2:
  9. count: 3
  10. image: ami-0cca6df87334a74bd
  11. instance_tags:
  12. type: webinar
  13. instance_type: t2.micro
  14. key_name: webinar
  15. wait: true
  16. user_data: "apt-get update && apt-get upgrade -y&& apt-get install -y python python-pip"
  17. name: "create machine"
  18. register: ec2
  19. -
  20. name: run ssh-keyscan to add keys to known_hosts
  21. local_action: shell ssh-keyscan {{ item.public_ip }} >> ~/.ssh/known_hosts
  22. with_items: "{{ ec2.instances }}"