build_node_image.yml 3.2 KB

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