build_ami.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ---
  2. - hosts: localhost
  3. connection: local
  4. gather_facts: no
  5. tasks:
  6. - name: Require openshift_aws_base_ami
  7. fail:
  8. msg: "A base AMI is required for AMI building. Please ensure `openshift_aws_base_ami` is defined."
  9. when: openshift_aws_base_ami is undefined
  10. - name: "Alert user to variables needed and their values - {{ item.name }}"
  11. debug:
  12. msg: "{{ item.msg }}"
  13. with_items:
  14. - name: openshift_aws_clusterid
  15. msg: "openshift_aws_clusterid={{ openshift_aws_clusterid | default('default') }}"
  16. - name: openshift_aws_region
  17. msg: "openshift_aws_region={{ openshift_aws_region | default('us-east-1') }}"
  18. - name: create an instance and prepare for ami
  19. include_role:
  20. name: openshift_aws
  21. tasks_from: build_ami.yml
  22. vars:
  23. openshift_aws_node_group_type: compute
  24. - name: fetch newly created instances
  25. ec2_remote_facts:
  26. region: "{{ openshift_aws_region | default('us-east-1') }}"
  27. filters:
  28. "tag:Name": "{{ openshift_aws_base_ami_name | default('ami_base') }}"
  29. instance-state-name: running
  30. register: instancesout
  31. retries: 20
  32. delay: 3
  33. until: instancesout.instances|length > 0
  34. - name: wait for ssh to become available
  35. wait_for:
  36. port: 22
  37. host: "{{ instancesout.instances[0].public_ip_address }}"
  38. timeout: 300
  39. search_regex: OpenSSH
  40. - name: add host to nodes
  41. add_host:
  42. groups: nodes
  43. name: "{{ instancesout.instances[0].public_dns_name }}"
  44. - name: set the user to perform installation
  45. set_fact:
  46. ansible_ssh_user: root
  47. - name: normalize groups
  48. include: ../../byo/openshift-cluster/initialize_groups.yml
  49. - name: run the std_include
  50. include: ../../common/openshift-cluster/evaluate_groups.yml
  51. - name: run the std_include
  52. include: ../../common/openshift-cluster/initialize_facts.yml
  53. - name: run the std_include
  54. include: ../../common/openshift-cluster/initialize_openshift_repos.yml
  55. - hosts: nodes
  56. remote_user: root
  57. tasks:
  58. - set_fact:
  59. openshift_node_bootstrap: True
  60. - name: run openshift image preparation
  61. include_role:
  62. name: openshift_node
  63. - hosts: localhost
  64. connection: local
  65. become: no
  66. tasks:
  67. - name: seal the ami
  68. include_role:
  69. name: openshift_aws
  70. tasks_from: seal_ami.yml
  71. vars:
  72. openshift_aws_ami_name: "openshift-gi-{{ lookup('pipe', 'date +%Y%m%d%H%M')}}"