main.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 != ''
  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. # The 1.1 release of the xpaas content for OpenShift renamed all the templates
  86. - name: Remove old xpaas templates from filesystem
  87. file:
  88. path: "{{ xpaas_templates_base }}/{{ item }}"
  89. state: absent
  90. with_items:
  91. - amq6-persistent.json
  92. - amq6.json
  93. - eap6-amq-persistent-sti.json
  94. - eap6-amq-sti.json
  95. - eap6-basic-sti.json
  96. - eap6-https-sti.json
  97. - eap6-mongodb-persistent-sti.json
  98. - eap6-mongodb-sti.json
  99. - eap6-mysql-persistent-sti.json
  100. - eap6-mysql-sti.json
  101. - eap6-postgresql-persistent-sti.json
  102. - eap6-postgresql-sti.json
  103. - jws-tomcat7-basic-sti.json
  104. - jws-tomcat7-https-sti.json
  105. - jws-tomcat7-mongodb-sti.json
  106. - jws-tomcat7-mongodb-persistent-sti.json
  107. - jws-tomcat7-mysql-persistent-sti.json
  108. - jws-tomcat7-mysql-sti.json
  109. - jws-tomcat7-postgresql-persistent-sti.json
  110. - jws-tomcat8-postgresql-persistent-sti.json
  111. - jws-tomcat8-basic-sti.json
  112. - jws-tomcat8-https-sti.json
  113. - jws-tomcat8-mongodb-sti.json
  114. - jws-tomcat8-mongodb-persistent-sti.json
  115. - jws-tomcat8-mysql-sti.json
  116. - jws-tomcat8-mysql-persistent-sti.json
  117. - jws-tomcat8-postgresql-sti.json
  118. - jws-tomcat7-postgresql-sti.json
  119. - name: Remove old xpaas templates from openshift namespace
  120. command: >
  121. {{ openshift.common.client_binary }} -n openshift delete
  122. templates/amq6 templates/amq6-persistent templates/eap6-amq-persistent-sti templates/eap6-amq-sti \
  123. templates/eap6-basic-sti templates/eap6-basic-sti templates/eap6-mongodb-persistent-sti templates/eap6-mongodb-sti \
  124. templates/eap6-mysql-persistent-sti templates/eap6-mysql-sti templates/eap6-postgresql-persistent-sti \
  125. templates/eap6-postgresql-sti templates/jws-tomcat7-basic-sti templates/jws-tomcat7-basic-sti \
  126. templates/jws-tomcat7-mongodb-persistent-sti templates/jws-tomcat7-mongodb-sti \
  127. templates/jws-tomcat7-mysql-persistent-sti templates/jws-tomcat7-mysql-sti \
  128. templates/jws-tomcat7-postgresql-persistent-sti templates/jws-tomcat7-postgresql-sti \
  129. templates/jws-tomcat8-basic-sti templates/jws-tomcat8-basic-sti templates/jws-tomcat8-mongodb-persistent-sti
  130. when: openshift_examples_load_xpaas | bool
  131. register: oex_delete_old_xpaas_templates
  132. failed_when: "'not found' not in oex_delete_old_xpaas_templates.stderr and oex_delete_old_xpaas_templates.rc != 0"
  133. changed_when: false
  134. - name: Import xPaas image streams
  135. command: >
  136. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_image_streams }}
  137. when: openshift_examples_load_xpaas | bool
  138. register: oex_import_xpaas_streams
  139. failed_when: "'already exists' not in oex_import_xpaas_streams.stderr and oex_import_xpaas_streams.rc != 0"
  140. changed_when: false
  141. - name: Import xPaas templates
  142. command: >
  143. {{ openshift.common.client_binary }} {{ openshift_examples_import_command }} -n openshift -f {{ xpaas_templates_base }}
  144. when: openshift_examples_load_xpaas | bool
  145. register: oex_import_xpaas_templates
  146. failed_when: "'already exists' not in oex_import_xpaas_templates.stderr and oex_import_xpaas_templates.rc != 0"
  147. changed_when: false