build_base_image.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. - hosts: nodes
  11. tasks:
  12. - name: calculate yum repositories
  13. set_fact:
  14. openshift_additional_repos: "{{ azure_base_repos[ansible_distribution] }}"
  15. - name: configure yum repositories
  16. import_tasks: tasks/yum_certs.yml
  17. - name: update rpms
  18. import_role:
  19. name: os_update_latest
  20. vars:
  21. os_update_latest_reboot: True
  22. - name: deconfigure yum repositories
  23. import_tasks: tasks/remove_yum.yml
  24. - name: run waagent deprovision
  25. command: waagent -deprovision+user -force
  26. args:
  27. chdir: /
  28. - hosts: localhost
  29. gather_facts: no
  30. tasks:
  31. - name: get current date/time
  32. shell: TZ=Etc/UTC date +%Y%m%d%H%M
  33. register: now
  34. - set_fact:
  35. image_name: "{{ openshift_azure_output_image_prefix }}-{{ now.stdout }}"
  36. - name: create image
  37. import_tasks: tasks/create_image_from_vm.yml
  38. vars:
  39. image_resource_group: "{{ openshift_azure_output_image_ns }}"
  40. image_tags:
  41. root_image: "{{ (input_image.stdout | from_json).name }}"
  42. kernel: "{{ hostvars[groups['nodes'][0]]['ansible_kernel'] }}"
  43. - name: create blob
  44. import_tasks: tasks/create_blob_from_vm.yml
  45. when: openshift_azure_storage_account is defined and openshift_azure_storage_account