main.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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: Remove defunct quickstart template files
  67. file:
  68. path: "{{ item }}"
  69. state: absent
  70. with_items:
  71. - "{{ quickstarts_base }}/nodejs.json"
  72. - "{{ quickstarts_base }}/cakephp.json"
  73. - "{{ quickstarts_base }}/dancer.json"
  74. - "{{ quickstarts_base }}/django.json"
  75. - name: Remove defunct quickstart templates from openshift namespace
  76. command: "{{ openshift.common.client_binary }} -n openshift delete templates/{{ item }}"
  77. with_items:
  78. - nodejs-example
  79. - cakephp-example
  80. - dancer-example
  81. - django-example
  82. register: oex_delete_defunct_quickstart_templates
  83. failed_when: "'not found' not in oex_delete_defunct_quickstart_templates.stderr and oex_delete_defunct_quickstart_templates.rc != 0"
  84. changed_when: false
  85. - name: Import quickstart-templates
  86. command: >
  87. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ quickstarts_base }}
  88. when: openshift_examples_load_quickstarts | bool
  89. register: oex_import_quickstarts
  90. failed_when: "'already exists' not in oex_import_quickstarts.stderr and oex_import_quickstarts.rc != 0"
  91. changed_when: false
  92. - name: Import origin infrastructure-templates
  93. command: >
  94. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ infrastructure_origin_base }}
  95. when: openshift_examples_load_centos | bool
  96. register: oex_import_infrastructure
  97. failed_when: "'already exists' not in oex_import_infrastructure.stderr and oex_import_infrastructure.rc != 0"
  98. changed_when: false
  99. - name: Import enterprise infrastructure-templates
  100. command: >
  101. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ infrastructure_enterprise_base }}
  102. when: openshift_examples_load_rhel | bool
  103. register: oex_import_infrastructure
  104. failed_when: "'already exists' not in oex_import_infrastructure.stderr and oex_import_infrastructure.rc != 0"
  105. changed_when: false
  106. - name: Remove old xPaas template files
  107. file:
  108. path: "{{ item }}"
  109. state: absent
  110. with_items:
  111. - "{{ xpaas_templates_base }}/sso70-basic.json"
  112. - name: Remove old xPaas templates from openshift namespace
  113. command: "{{ openshift.common.client_binary }} -n openshift delete templates/{{ item }}"
  114. with_items:
  115. - sso70-basic
  116. register: oex_delete_old_xpaas_templates
  117. failed_when: "'not found' not in oex_delete_old_xpaas_templates.stderr and oex_delete_old_xpaas_templates.rc != 0"
  118. changed_when: false
  119. - name: Import xPaas image streams
  120. command: >
  121. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_image_streams }}
  122. when: openshift_examples_load_xpaas | bool
  123. register: oex_import_xpaas_streams
  124. failed_when: "'already exists' not in oex_import_xpaas_streams.stderr and oex_import_xpaas_streams.rc != 0"
  125. changed_when: false
  126. - name: Import xPaas templates
  127. command: >
  128. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_templates_base }}
  129. when: openshift_examples_load_xpaas | bool
  130. register: oex_import_xpaas_templates
  131. failed_when: "'already exists' not in oex_import_xpaas_templates.stderr and oex_import_xpaas_templates.rc != 0"
  132. changed_when: false