main.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ---
  2. ######################################################################
  3. # Copying Examples
  4. #
  5. # We used to use the copy module to transfer the openshift examples to
  6. # the remote. Then it started taking more than a minute to transfer
  7. # the files. As noted in the module:
  8. #
  9. # "The 'copy' module recursively copy facility does not scale to
  10. # lots (>hundreds) of files."
  11. #
  12. # The `synchronize` module is suggested as an alternative, we can't
  13. # use it either due to changes introduced in Ansible 2.x.
  14. - name: Create local temp dir for OpenShift examples copy
  15. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  16. become: False
  17. register: copy_examples_mktemp
  18. run_once: True
  19. - name: Create tar of OpenShift examples
  20. local_action: command tar -C "{{ role_path }}/files/examples/{{ content_version }}/" -cvf "{{ copy_examples_mktemp.stdout }}/openshift-examples.tar" .
  21. become: False
  22. register: copy_examples_tar
  23. - name: Create the remote OpenShift examples directory
  24. file:
  25. dest: "{{ examples_base }}"
  26. state: directory
  27. mode: 0755
  28. - name: Unarchive the OpenShift examples on the remote
  29. unarchive:
  30. src: "{{ copy_examples_mktemp.stdout }}/openshift-examples.tar"
  31. dest: "{{ examples_base }}/"
  32. - name: Cleanup the OpenShift Examples temp dir
  33. become: False
  34. local_action: file dest="{{ copy_examples_mktemp.stdout }}" state=absent
  35. # Done copying examples
  36. ######################################################################
  37. # Begin image streams
  38. - name: Modify registry paths if registry_url is not registry.access.redhat.com
  39. shell: >
  40. find {{ examples_base }} -type f | xargs -n 1 sed -i 's|registry.access.redhat.com|{{ registry_host | quote }}|g'
  41. when: registry_host != '' and openshift_examples_modify_imagestreams | default(False) | bool
  42. # RHEL and Centos image streams are mutually exclusive
  43. - name: Import RHEL streams
  44. command: >
  45. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ item }}
  46. when: openshift_examples_load_rhel | bool
  47. with_items:
  48. - "{{ rhel_image_streams }}"
  49. register: oex_import_rhel_streams
  50. failed_when: "'already exists' not in oex_import_rhel_streams.stderr and oex_import_rhel_streams.rc != 0"
  51. changed_when: false
  52. - name: Import Centos Image streams
  53. command: >
  54. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ centos_image_streams }}
  55. when: openshift_examples_load_centos | bool
  56. register: oex_import_centos_streams
  57. failed_when: "'already exists' not in oex_import_centos_streams.stderr and oex_import_centos_streams.rc != 0"
  58. changed_when: false
  59. - name: Import db templates
  60. command: >
  61. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ db_templates_base }}
  62. when: openshift_examples_load_db_templates | bool
  63. register: oex_import_db_templates
  64. failed_when: "'already exists' not in oex_import_db_templates.stderr and oex_import_db_templates.rc != 0"
  65. changed_when: false
  66. - name: Import quickstart-templates
  67. command: >
  68. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ quickstarts_base }}
  69. when: openshift_examples_load_quickstarts | bool
  70. register: oex_import_quickstarts
  71. failed_when: "'already exists' not in oex_import_quickstarts.stderr and oex_import_quickstarts.rc != 0"
  72. changed_when: false
  73. - name: Import origin infrastructure-templates
  74. command: >
  75. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ infrastructure_origin_base }}
  76. when: openshift_examples_load_centos | bool
  77. register: oex_import_infrastructure
  78. failed_when: "'already exists' not in oex_import_infrastructure.stderr and oex_import_infrastructure.rc != 0"
  79. changed_when: false
  80. - name: Import enterprise infrastructure-templates
  81. command: >
  82. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ infrastructure_enterprise_base }}
  83. when: openshift_examples_load_rhel | bool
  84. register: oex_import_infrastructure
  85. failed_when: "'already exists' not in oex_import_infrastructure.stderr and oex_import_infrastructure.rc != 0"
  86. changed_when: false
  87. - name: Remove old xPaas template files
  88. file:
  89. path: "{{ item }}"
  90. state: absent
  91. with_items:
  92. - "{{ xpaas_templates_base }}/sso70-basic.json"
  93. - name: Remove old xPaas templates from openshift namespace
  94. command: "{{ openshift.common.client_binary }} -n openshift delete templates/{{ item }}"
  95. with_items:
  96. - sso70-basic
  97. register: oex_delete_old_xpaas_templates
  98. failed_when: "'not found' not in oex_delete_old_xpaas_templates.stderr and oex_delete_old_xpaas_templates.rc != 0"
  99. changed_when: false
  100. - name: Import xPaas image streams
  101. command: >
  102. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_image_streams }}
  103. when: openshift_examples_load_xpaas | bool
  104. register: oex_import_xpaas_streams
  105. failed_when: "'already exists' not in oex_import_xpaas_streams.stderr and oex_import_xpaas_streams.rc != 0"
  106. changed_when: false
  107. - name: Import xPaas templates
  108. command: >
  109. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_templates_base }}
  110. when: openshift_examples_load_xpaas | bool
  111. register: oex_import_xpaas_templates
  112. failed_when: "'already exists' not in oex_import_xpaas_templates.stderr and oex_import_xpaas_templates.rc != 0"
  113. changed_when: false