main.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ---
  2. - name: Create temp file for template
  3. command: mktemp /tmp/openshift-ansible-XXXXXX.yaml
  4. register: mktemp
  5. changed_when: False
  6. - name: Generate default project template
  7. command: |
  8. {{ openshift.common.client_binary | quote }} \
  9. --config {{ openshift.common.config_base | quote }}/master/admin.kubeconfig \
  10. --output yaml \
  11. adm create-bootstrap-project-template \
  12. --name {{ openshift_project_request_template_name | quote }}
  13. register: default_project_template
  14. - name: Write default project template to file
  15. copy:
  16. mode=0600
  17. content="{{ default_project_template.stdout }}"
  18. dest="{{ mktemp.stdout }}"
  19. - name: Apply template modifications
  20. yedit:
  21. state: present
  22. src: "{{ mktemp.stdout }}"
  23. edits: "{{ openshift_project_request_template_edits }}"
  24. when: "openshift_project_request_template_edits | length > 0"
  25. - name: Create or update project request template
  26. command: |
  27. {{ openshift.common.client_binary }} \
  28. --config {{ openshift.common.config_base }}/master/admin.kubeconfig \
  29. --namespace {{ openshift_project_request_template_namespace | quote }} \
  30. apply --filename {{ mktemp.stdout }}
  31. - name: Delete temp file
  32. file:
  33. name: "{{ mktemp.stdout }}"
  34. state: absent
  35. changed_when: False