main.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 {{ rhel_image_streams }}
  46. when: openshift_examples_load_rhel | bool
  47. register: oex_import_rhel_streams
  48. failed_when: "'already exists' not in oex_import_rhel_streams.stderr and oex_import_rhel_streams.rc != 0"
  49. changed_when: false
  50. - name: Import Centos Image streams
  51. command: >
  52. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ centos_image_streams }}
  53. when: openshift_examples_load_centos | bool
  54. register: oex_import_centos_streams
  55. failed_when: "'already exists' not in oex_import_centos_streams.stderr and oex_import_centos_streams.rc != 0"
  56. changed_when: false
  57. - name: Import db templates
  58. command: >
  59. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ db_templates_base }}
  60. when: openshift_examples_load_db_templates | bool
  61. register: oex_import_db_templates
  62. failed_when: "'already exists' not in oex_import_db_templates.stderr and oex_import_db_templates.rc != 0"
  63. changed_when: false
  64. - name: Import quickstart-templates
  65. command: >
  66. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ quickstarts_base }}
  67. when: openshift_examples_load_quickstarts | bool
  68. register: oex_import_quickstarts
  69. failed_when: "'already exists' not in oex_import_quickstarts.stderr and oex_import_quickstarts.rc != 0"
  70. changed_when: false
  71. - name: Import origin infrastructure-templates
  72. command: >
  73. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ infrastructure_origin_base }}
  74. when: openshift_examples_load_centos | bool
  75. register: oex_import_infrastructure
  76. failed_when: "'already exists' not in oex_import_infrastructure.stderr and oex_import_infrastructure.rc != 0"
  77. changed_when: false
  78. - name: Import enterprise infrastructure-templates
  79. command: >
  80. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ infrastructure_enterprise_base }}
  81. when: openshift_examples_load_rhel | bool
  82. register: oex_import_infrastructure
  83. failed_when: "'already exists' not in oex_import_infrastructure.stderr and oex_import_infrastructure.rc != 0"
  84. changed_when: false
  85. - name: Import xPaas image streams
  86. command: >
  87. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_image_streams }}
  88. when: openshift_examples_load_xpaas | bool
  89. register: oex_import_xpaas_streams
  90. failed_when: "'already exists' not in oex_import_xpaas_streams.stderr and oex_import_xpaas_streams.rc != 0"
  91. changed_when: false
  92. - name: Import xPaas templates
  93. command: >
  94. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_templates_base }}
  95. when: openshift_examples_load_xpaas | bool
  96. register: oex_import_xpaas_templates
  97. failed_when: "'already exists' not in oex_import_xpaas_templates.stderr and oex_import_xpaas_templates.rc != 0"
  98. changed_when: false