oc_apply.yaml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. when: namespace is defined
  13. - name: Checking generation of {{file_content.kind}} {{file_content.metadata.name}}
  14. command: >
  15. {{ openshift_client_binary }}
  16. --config={{ kubeconfig }}
  17. get {{file_content.kind}} {{file_content.metadata.name}}
  18. -o jsonpath='{.metadata.resourceVersion}'
  19. register: generation_init_no_ns
  20. failed_when: false
  21. changed_when: no
  22. when: namespace is not defined
  23. - name: Applying {{file_name}}
  24. command: >
  25. {{ openshift_client_binary }} --config={{ kubeconfig }}
  26. apply -f {{ file_name }}
  27. -n {{namespace}}
  28. register: generation_apply
  29. failed_when: "'error' in generation_apply.stderr or (generation_apply.rc | int != 0)"
  30. changed_when: no
  31. when: namespace is defined
  32. - name: Applying {{file_name}}
  33. command: >
  34. {{ openshift_client_binary }} --config={{ kubeconfig }}
  35. apply -f {{ file_name }}
  36. register: generation_apply
  37. failed_when: "'error' in generation_apply.stderr or (generation_apply.rc | int != 0)"
  38. changed_when: no
  39. when: namespace is not defined
  40. - name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
  41. command: >
  42. {{ openshift_client_binary }} --config={{ kubeconfig }}
  43. get {{file_content.kind}} {{file_content.metadata.name}}
  44. -o jsonpath='{.metadata.resourceVersion}'
  45. -n {{namespace}}
  46. register: version_changed
  47. vars:
  48. init_version: "{{ (generation_init is defined) | ternary(generation_init.stdout, '0') }}"
  49. failed_when: "'error' in version_changed.stderr or version_changed.rc | int != 0"
  50. changed_when: version_changed.stdout | int > init_version | int
  51. when: namespace is defined
  52. - name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
  53. command: >
  54. {{ openshift_client_binary }} --config={{ kubeconfig }}
  55. get {{file_content.kind}} {{file_content.metadata.name}}
  56. -o jsonpath='{.metadata.resourceVersion}'
  57. register: version_changed
  58. vars:
  59. init_version: "{{ (generation_init_no_ns is defined) | ternary(generation_init_no_ns.stdout, '0') }}"
  60. failed_when: "'error' in version_changed.stderr or version_changed.rc | int != 0"
  61. changed_when: version_changed.stdout | int > init_version | int
  62. when: namespace is not defined