build_ami.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. - when: openshift_aws_create_vpc | bool
  3. name: create a vpc
  4. include: vpc.yml
  5. - when: openshift_aws_users | length > 0
  6. name: create aws ssh keypair
  7. include: ssh_keys.yml
  8. - when: openshift_aws_create_security_groups | bool
  9. name: Create compute security_groups
  10. include: security_group.yml
  11. - name: query vpc
  12. ec2_vpc_net_facts:
  13. region: "{{ openshift_aws_region }}"
  14. filters:
  15. 'tag:Name': "{{ openshift_aws_vpc_name }}"
  16. register: vpcout
  17. - name: fetch the default subnet id
  18. ec2_vpc_subnet_facts:
  19. region: "{{ openshift_aws_region }}"
  20. filters:
  21. "tag:Name": "{{ openshift_aws_subnet_name }}"
  22. vpc-id: "{{ vpcout.vpcs[0].id }}"
  23. register: subnetout
  24. - name: create instance for ami creation
  25. ec2:
  26. assign_public_ip: yes
  27. region: "{{ openshift_aws_region }}"
  28. key_name: "{{ openshift_aws_ssh_key_name }}"
  29. group: "{{ openshift_aws_clusterid }}"
  30. instance_type: m4.xlarge
  31. vpc_subnet_id: "{{ subnetout.subnets[0].id }}"
  32. image: "{{ openshift_aws_base_ami }}"
  33. volumes:
  34. - device_name: /dev/sdb
  35. volume_type: gp2
  36. volume_size: 100
  37. delete_on_termination: true
  38. wait: yes
  39. exact_count: 1
  40. count_tag:
  41. Name: "{{ openshift_aws_base_ami_name }}"
  42. instance_tags:
  43. Name: "{{ openshift_aws_base_ami_name }}"