main.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ---
  2. - name: Create local temp dir for OpenShift hosted templates copy
  3. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  4. become: False
  5. register: copy_hosted_templates_mktemp
  6. run_once: True
  7. # AUDIT:changed_when: not set here because this task actually
  8. # creates something
  9. - name: Create tar of OpenShift examples
  10. local_action: command tar -C "{{ role_path }}/files/{{ content_version }}/{{ hosted_deployment_type }}" -cvf "{{ copy_hosted_templates_mktemp.stdout }}/openshift-hosted-templates.tar" .
  11. args:
  12. # Disables the following warning:
  13. # Consider using unarchive module rather than running tar
  14. warn: no
  15. become: False
  16. register: copy_hosted_templates_tar
  17. - name: Create remote OpenShift hosted templates directory
  18. file:
  19. dest: "{{ hosted_base }}"
  20. state: directory
  21. mode: 0755
  22. - name: Unarchive the OpenShift hosted templates on the remote
  23. unarchive:
  24. src: "{{ copy_hosted_templates_mktemp.stdout }}/openshift-hosted-templates.tar"
  25. dest: "{{ hosted_base }}/"
  26. - name: Cleanup the OpenShift hosted templates temp dir
  27. become: False
  28. local_action: file dest="{{ copy_hosted_templates_mktemp.stdout }}" state=absent
  29. - name: Modify registry paths if registry_url is not registry.access.redhat.com
  30. shell: >
  31. find {{ hosted_base }} -type f | xargs -n 1 sed -i 's|registry.access.redhat.com|{{ registry_host | quote }}|g'
  32. when: registry_host != '' and openshift_hosted_modify_imagestreams | default(openshift_examples_modify_imagestreams | default(False)) | bool
  33. - name: Create temp directory for kubeconfig
  34. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  35. register: mktemp
  36. changed_when: False
  37. - name: Record kubeconfig tmp dir
  38. set_fact:
  39. openshift_hosted_templates_kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
  40. - name: Copy the admin client config(s)
  41. command: >
  42. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ openshift_hosted_templates_kubeconfig }}
  43. changed_when: False
  44. - name: Create or update hosted templates
  45. command: >
  46. {{ openshift_client_binary }} {{ openshift_hosted_templates_import_command }}
  47. -f {{ hosted_base }}
  48. --config={{ openshift_hosted_templates_kubeconfig }}
  49. -n openshift
  50. register: oht_import_templates
  51. failed_when: "'already exists' not in oht_import_templates.stderr and oht_import_templates.rc != 0"
  52. changed_when: "'created' in oht_import_templates.stdout"
  53. - name: Delete temp directory
  54. file:
  55. name: "{{ mktemp.stdout }}"
  56. state: absent
  57. changed_when: False