build_node_image.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. openshift_node_include_control_plane: True
  22. openshift_control_plane_static_pod_location: /etc/origin/node/disabled/
  23. - set_fact:
  24. openshift_additional_repos: "{{ openshift_additional_repos + [{'name': 'install_repo', 'baseurl': openshift_azure_install_repo, 'enabled': true, 'gpgcheck': false}] }}"
  25. when: openshift_azure_install_repo is defined and openshift_azure_install_repo
  26. - name: install centos-release-paas-common rpm
  27. yum:
  28. name: centos-release-paas-common
  29. state: present
  30. when: ansible_distribution == "CentOS"
  31. - name: configure yum repositories
  32. import_tasks: tasks/yum_certs.yml
  33. - name: update rpms
  34. import_role:
  35. name: os_update_latest
  36. vars:
  37. os_update_latest_reboot: True
  38. - name: install openshift
  39. import_playbook: ../../openshift-node/private/image_prep.yml
  40. - hosts: nodes
  41. tasks:
  42. - name: deconfigure yum repositories
  43. import_tasks: tasks/remove_yum.yml
  44. - name: record installed rpms
  45. yum:
  46. list: installed
  47. register: yum
  48. - name: run waagent deprovision
  49. shell: sleep 2 && waagent -deprovision+user -force
  50. async: 1
  51. poll: 0
  52. - hosts: localhost
  53. gather_facts: no
  54. tasks:
  55. - name: get current date/time
  56. shell: TZ=Etc/UTC date +%Y%m%d%H%M
  57. register: now
  58. - set_fact:
  59. openshift_rpm: "{{ hostvars[groups['nodes'][0]]['yum'].results | selectattr('name', 'match', '^(origin|atomic-openshift)$') | first }}"
  60. - set_fact:
  61. image_name: "{{ openshift_azure_output_image_prefix }}-{{ openshift_rpm.version | regex_replace('^(\\d+\\.\\d+).*', '\\1') }}-{{ now.stdout }}"
  62. - name: create image
  63. import_tasks: tasks/create_image_from_vm.yml
  64. vars:
  65. image_resource_group: "{{ openshift_azure_output_image_ns }}"
  66. image_tags:
  67. base_image: "{{ (input_image.stdout | from_json).name }}"
  68. kernel: "{{ hostvars[groups['nodes'][0]]['ansible_kernel'] }}"
  69. openshift: "{{ openshift_rpm.name }}-{{ openshift_rpm.version }}-{{ openshift_rpm.release }}.{{ openshift_rpm.arch }}"
  70. - name: create blob
  71. import_tasks: tasks/create_blob_from_vm.yml
  72. when: openshift_azure_storage_account is defined and openshift_azure_storage_account