oc_apply.yaml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ---
  2. - name: Checking generation of {{file_content.kind}} {{file_content.metadata.name}}
  3. command: >
  4. {{ openshift_client_binary }}
  5. --config={{ kubeconfig }}
  6. get {{file_content.kind}} {{file_content.metadata.name}}
  7. -o jsonpath='{.metadata.resourceVersion}'
  8. -n {{namespace}}
  9. register: generation_init
  10. failed_when: false
  11. changed_when: no
  12. - name: Applying {{file_name}}
  13. command: >
  14. {{ openshift_client_binary }} --config={{ kubeconfig }}
  15. apply -f {{ file_name }}
  16. -n {{namespace}}
  17. register: generation_apply
  18. failed_when:
  19. - "'error' in generation_apply.stderr"
  20. - "generation_apply.rc != 0"
  21. changed_when: no
  22. - name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
  23. command: >
  24. {{ openshift_client_binary }} --config={{ kubeconfig }}
  25. get {{file_content.kind}} {{file_content.metadata.name}}
  26. -o jsonpath='{.metadata.resourceVersion}'
  27. -n {{namespace}}
  28. register: version_changed
  29. vars:
  30. init_version: "{{ (generation_init is defined) | ternary(generation_init.stdout, '0') }}"
  31. failed_when:
  32. - "'error' in version_changed.stderr"
  33. - "version_changed.rc != 0"
  34. changed_when: version_changed.stdout | int > init_version | int