build_node_image.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ---
  2. - hosts: localhost
  3. gather_facts: no
  4. tasks:
  5. - name: calculate input image
  6. command: az image list -g "{{ openshift_azure_input_image_ns }}" --query "[?starts_with(name, '{{ openshift_azure_input_image_prefix }}-') && tags.valid=='true'] | sort_by(@, &name) | [-1]"
  7. register: input_image
  8. - name: provision resource group
  9. import_tasks: tasks/provision_instance.yml
  10. vars:
  11. create_args: --data-disk-sizes-gb 128
  12. - hosts: nodes
  13. tasks:
  14. - set_fact:
  15. openshift_deployment_type: "{{ 'openshift-enterprise' if ansible_distribution == 'RedHat' else 'origin' }}"
  16. openshift_enable_origin_repo: False
  17. skip_node_svc_handlers: True
  18. openshift_additional_repos: "{{ azure_node_repos[ansible_distribution] }}"
  19. openshift_node_open_ports: [{"service":"Node exporter metrics", "port":"9100/tcp"}]
  20. openshift_node_include_control_plane: True
  21. openshift_control_plane_static_pod_location: /etc/origin/node/disabled/
  22. openshift_node_group_cloud_provider: azure
  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. vars:
  49. etcd_image: "{{ etcd_image_dict[openshift_deployment_type] }}"
  50. - hosts: nodes
  51. tasks:
  52. - name: deconfigure yum repositories
  53. import_tasks: tasks/remove_yum.yml
  54. - name: add get-node-logs script
  55. copy:
  56. src: files/get-node-logs
  57. dest: /usr/local/bin/get-node-logs
  58. owner: root
  59. group: root
  60. mode: 0755
  61. - name: record installed rpms
  62. yum:
  63. list: installed
  64. register: yum
  65. - name: disable waagent data disk management
  66. lineinfile:
  67. path: /etc/waagent.conf
  68. regexp: "{{ item.regexp }}"
  69. line: "{{ item.line }}"
  70. with_items:
  71. - { regexp: '^ResourceDisk\.Format=', line: 'ResourceDisk.Format=n' }
  72. - name: persist oreg_url
  73. copy:
  74. dest: "/etc/origin/oreg_url"
  75. content: "{{ oreg_url }}"
  76. when: oreg_url is defined
  77. - name: run waagent deprovision
  78. shell: sleep 2 && waagent -deprovision+user -force
  79. async: 1
  80. poll: 0
  81. - hosts: localhost
  82. gather_facts: no
  83. tasks:
  84. - set_fact:
  85. openshift_rpm: "{{ hostvars[groups['nodes'][0]]['yum'].results | selectattr('name', 'match', '^(origin|atomic-openshift)$') | first }}"
  86. - name: create image
  87. import_tasks: tasks/create_image_from_vm.yml
  88. vars:
  89. image_resource_group: "{{ openshift_azure_output_image_ns }}"
  90. image_name: "{{ openshift_azure_output_image_name }}"
  91. image_tags:
  92. base_image: "{{ (input_image.stdout | from_json).name }}"
  93. kernel: "{{ hostvars[groups['nodes'][0]]['ansible_kernel'] }}"
  94. openshift: "{{ openshift_rpm.name }}-{{ openshift_rpm.version }}-{{ openshift_rpm.release }}.{{ openshift_rpm.arch }}"
  95. - name: create blob
  96. import_tasks: tasks/create_blob_from_vm.yml
  97. vars:
  98. image_name: "{{ openshift_azure_output_image_name }}"
  99. when: openshift_azure_storage_account is defined and openshift_azure_storage_account