Guest User

Untitled

a guest
Feb 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. ---
  2. - name: Provision EC2 Box
  3. local_action:
  4. module: ec2
  5. key_name: "{{ ec2_keypair }}"
  6. group_id: "{{ ec2_security_group }}"
  7. instance_type: "{{ ec2_instance_type }}"
  8. image: "{{ ec2_image }}"
  9. vpc_subnet_id: "{{ ec2_subnet_ids|random }}"
  10. region: "{{ ec2_region }}"
  11. instance_tags: '{"Name":"{{ec2_tag_Name}}","Type":"{{ec2_tag_Type}}","Environment":"{{ec2_tag_Environment}}"}'
  12. assign_public_ip: yes
  13. wait: true
  14. count: 1
  15. volumes:
  16. - device_name: /dev/sda1
  17. device_type: gp2
  18. volume_size: "{{ ec2_volume_size }}"
  19. delete_on_termination: true
  20. register: ec2
  21.  
  22. - debug: var=item
  23. with_items: ec2.instances
  24.  
  25. - add_host: name={{ item.public_ip }} >
  26. groups=tag_Type_{{ec2_tag_Type}},tag_Environment_{{ec2_tag_Environment}}
  27. ec2_region={{ec2_region}}
  28. ec2_tag_Name={{ec2_tag_Name}}
  29. ec2_tag_Type={{ec2_tag_Type}}
  30. ec2_tag_Environment={{ec2_tag_Environment}}
  31. ec2_ip_address={{item.public_ip}}
  32. with_items: ec2.instances
  33.  
  34. - name: Wait for the instances to boot by checking the ssh port
  35. wait_for: host={{item.public_ip}} port=22 delay=60 timeout=320 state=started
  36. with_items: ec2.instances
Add Comment
Please, Sign In to add comment