main.yml 2.3 KB

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