create_config.yml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. - name: create volume config template
  42. template:
  43. src: volume-config.yaml.j2
  44. dest: "{{ mktempout.stdout }}/volume-config.yaml"
  45. when:
  46. - configout.results.results.0 == {} and openshift_node_group_name != "" and openshift_node_local_quota_per_fsgroup is defined and openshift_node_local_quota_per_fsgroup != ""
  47. run_once: true
  48. - name: lay down the volume config from the existing configmap
  49. copy:
  50. content: "{{ configout.results.results.0.data['volume-config.yaml'] }}"
  51. dest: "{{ mktempout.stdout }}/volume-config.yaml"
  52. when:
  53. - configout.results.results.0 != {} and openshift_node_group_name != "" and openshift_node_local_quota_per_fsgroup is defined and openshift_node_local_quota_per_fsgroup != ""
  54. run_once: true
  55. - debug: var=yeditout
  56. run_once: true
  57. - name: create node-config.yaml configmap
  58. oc_configmap:
  59. name: "{{ openshift_node_group_name }}"
  60. namespace: "{{ openshift_node_group_namespace }}"
  61. from_file:
  62. node-config.yaml: "{{ mktempout.stdout }}/node-config.yaml"
  63. when:
  64. - openshift_node_local_quota_per_fsgroup is undefined or openshift_node_local_quota_per_fsgroup == ""
  65. run_once: true
  66. - name: create node-config.yaml and volume-config.yaml configmap
  67. oc_configmap:
  68. name: "{{ openshift_node_group_name }}"
  69. namespace: "{{ openshift_node_group_namespace }}"
  70. from_file:
  71. node-config.yaml: "{{ mktempout.stdout }}/node-config.yaml"
  72. volume-config.yaml: "{{ mktempout.stdout }}/volume-config.yaml"
  73. when:
  74. - openshift_node_local_quota_per_fsgroup is defined and openshift_node_local_quota_per_fsgroup != ""
  75. run_once: true
  76. - name: remove templated files
  77. file:
  78. dest: "{{ mktempout.stdout }}/"
  79. state: absent
  80. run_once: true