patch_configmap_files.yaml 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. ---
  2. ## The purpose of this task file is to take in a list of configmap files provided
  3. ## in the variable configmap_file_names, which correspond to the data sections
  4. ## within a configmap. We iterate over each of these files and create a patch
  5. ## from the diff between current_file and new_file to try to maintain any custom
  6. ## changes that a user may have made to a currently deployed configmap while
  7. ## trying to idempotently update with any role provided files.
  8. ## The following variables are expected to be provided when including this task:
  9. # configmap_name -- This is the name of the configmap that the files exist in
  10. # configmap_namespace -- The namespace that the configmap lives in
  11. # configmap_file_names -- This is expected to be passed in as a dict
  12. # current_file -- The name of the data entry within the configmap
  13. # new_file -- The file path to the file we are comparing to current_file
  14. # protected_lines -- List of variables whose line will be excluded when creating a diff
  15. - oc_configmap:
  16. name: "{{ configmap_name }}"
  17. state: list
  18. namespace: "{{ configmap_namespace }}"
  19. register: __configmap_output
  20. - when: __configmap_output.results.stderr is undefined
  21. include_tasks: patch_configmap_file.yaml
  22. vars:
  23. configmap_current_file: "{{ configmap_files.current_file }}"
  24. configmap_new_file: "{{ configmap_files.new_file }}"
  25. configmap_protected_lines: "{{ configmap_files.protected_lines | default([]) }}"
  26. with_items: "{{ configmap_file_names }}"
  27. loop_control:
  28. loop_var: configmap_files