create_config.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ---
  2. - name: fetch node configmap
  3. oc_configmap:
  4. name: "{{ openshift_node_group_name }}"
  5. namespace: "{{ openshift_node_group_namespace }}"
  6. state: list
  7. register: configout
  8. run_once: true
  9. - name: debug node config
  10. debug: var=configout
  11. run_once: true
  12. - when:
  13. - configout.results.results.0 == {} or (configout.results.results.0 != {} and openshift_node_group_edits|length > 0)
  14. block:
  15. - name: create a temp dir for this work
  16. command: mktemp -d /tmp/openshift_node_config-XXXXXX
  17. register: mktempout
  18. run_once: true
  19. - name: create node config template
  20. template:
  21. src: node-config.yaml.j2
  22. dest: "{{ mktempout.stdout }}/node-config.yaml"
  23. when:
  24. - configout.results.results.0 == {}
  25. run_once: true
  26. - name: lay down the config from the existing configmap
  27. copy:
  28. content: "{{ configout.results.results.0.data['node-config.yaml'] }}"
  29. dest: "{{ mktempout.stdout }}/node-config.yaml"
  30. when:
  31. - configout.results.results.0 != {}
  32. run_once: true
  33. - name: "specialize the generated configs for {{ openshift_node_group_name }}"
  34. yedit:
  35. content:
  36. src: "{{ mktempout.stdout }}/node-config.yaml"
  37. edits: "{{ openshift_node_group_edits }}"
  38. register: yeditout
  39. when: openshift_node_group_edits|length > 0
  40. run_once: true
  41. - debug: var=yeditout
  42. run_once: true
  43. - name: create node-config.yaml configmap
  44. oc_configmap:
  45. name: "{{ openshift_node_group_name }}"
  46. namespace: "{{ openshift_node_group_namespace }}"
  47. from_file:
  48. node-config.yaml: "{{ mktempout.stdout }}/node-config.yaml"
  49. run_once: true
  50. - name: remove templated files
  51. file:
  52. dest: "{{ mktempout.stdout }}/"
  53. state: absent
  54. run_once: true