build_node_image.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ---
  2. - hosts: localhost
  3. gather_facts: no
  4. tasks:
  5. - name: provision resource group
  6. import_tasks: tasks/provision_instance.yml
  7. vars:
  8. image_prefix: "{{ openshift_azure_input_image_prefix }}"
  9. image_resource_group: "{{ openshift_azure_input_image_ns }}"
  10. create_args: --data-disk-sizes-gb 128
  11. - set_fact:
  12. openshift_node_bootstrap: True
  13. - hosts: nodes
  14. tasks:
  15. - set_fact:
  16. openshift_deployment_type: "{{ 'openshift-enterprise' if ansible_distribution == 'RedHat' else 'origin' }}"
  17. openshift_enable_origin_repo: False
  18. openshift_node_bootstrap: True
  19. skip_node_svc_handlers: True
  20. openshift_additional_repos: "{{ azure_node_repos[ansible_distribution] }}"
  21. - set_fact:
  22. openshift_additional_repos: "{{ openshift_additional_repos + [{'name': 'install_repo', 'baseurl': openshift_azure_install_repo, 'enabled': true, 'gpgcheck': false}] }}"
  23. when: openshift_azure_install_repo is defined and openshift_azure_install_repo
  24. - name: install centos-release-paas-common rpm
  25. yum:
  26. name: centos-release-paas-common
  27. state: present
  28. when: ansible_distribution == "CentOS"
  29. - name: configure yum repositories
  30. import_tasks: tasks/yum_certs.yml
  31. - name: update rpms
  32. import_role:
  33. name: os_update_latest
  34. vars:
  35. os_update_latest_reboot: True
  36. - name: install openshift
  37. import_playbook: ../../openshift-node/private/image_prep.yml
  38. - hosts: nodes
  39. tasks:
  40. - name: deconfigure yum repositories
  41. import_tasks: tasks/remove_yum.yml
  42. - name: record installed rpms
  43. yum:
  44. list: installed
  45. register: yum
  46. - name: run waagent deprovision
  47. command: waagent -deprovision+user -force
  48. args:
  49. chdir: /
  50. - hosts: localhost
  51. gather_facts: no
  52. tasks:
  53. - name: get current date/time
  54. shell: TZ=Etc/UTC date +%Y%m%d%H%M
  55. register: now
  56. - set_fact:
  57. openshift_rpm: "{{ hostvars[groups['nodes'][0]]['yum'].results | selectattr('name', 'match', '^(origin|atomic-openshift)$') | first }}"
  58. - set_fact:
  59. image_name: "{{ openshift_azure_output_image_prefix }}-{{ openshift_rpm.version | regex_replace('^(\\d+\\.\\d+).*', '\\1') }}-{{ now.stdout }}"
  60. - name: create image
  61. import_tasks: tasks/create_image_from_vm.yml
  62. vars:
  63. image_resource_group: "{{ openshift_azure_output_image_ns }}"
  64. image_tags:
  65. base_image: "{{ (input_image.stdout | from_json).name }}"
  66. kernel: "{{ hostvars[groups['nodes'][0]]['ansible_kernel'] }}"
  67. openshift: "{{ openshift_rpm.name }}-{{ openshift_rpm.version }}-{{ openshift_rpm.release }}.{{ openshift_rpm.arch }}"
  68. - name: create blob
  69. import_tasks: tasks/create_blob_from_vm.yml
  70. when: openshift_azure_storage_account is defined and openshift_azure_storage_account