build_node_image.yml 3.2 KB

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