create_config.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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:
  11. var: configout
  12. run_once: true
  13. - when:
  14. - configout.results.results.0 == {} or (configout.results.results.0 != {} and (openshift_node_group_edits|length > 0 or openshift_node_group_labels|length > 0))
  15. block:
  16. - name: create a temp dir for this work
  17. command: mktemp -d /tmp/openshift_node_config-XXXXXX
  18. register: mktempout
  19. run_once: true
  20. - name: create node config template
  21. template:
  22. src: node-config.yaml.j2
  23. dest: "{{ mktempout.stdout }}/node-config.yaml"
  24. when:
  25. - configout.results.results.0 == {}
  26. run_once: true
  27. - name: lay down the config from the existing configmap
  28. copy:
  29. content: "{{ configout.results.results.0.data['node-config.yaml'] }}"
  30. dest: "{{ mktempout.stdout }}/node-config.yaml"
  31. when:
  32. - configout.results.results.0 != {}
  33. run_once: true
  34. - name: "specialize the generated configs for {{ openshift_node_group_name }}"
  35. yedit:
  36. content:
  37. src: "{{ mktempout.stdout }}/node-config.yaml"
  38. edits: "{{ openshift_node_group_edits | union(openshift_node_labels_edit) }}"
  39. register: yeditout
  40. run_once: true
  41. - name: show the yeditout debug var
  42. debug:
  43. var: yeditout
  44. run_once: true
  45. - name: create volume config template
  46. template:
  47. src: volume-config.yaml.j2
  48. dest: "{{ mktempout.stdout }}/volume-config.yaml"
  49. when:
  50. - "'data' not in configout['results']['results'][0] or 'volume-config.yaml' not in configout['results']['results'][0]['data']"
  51. - openshift_node_group_name != ""
  52. - openshift_node_local_quota_per_fsgroup is defined
  53. - openshift_node_local_quota_per_fsgroup != ""
  54. run_once: true
  55. - name: lay down the volume config from the existing configmap
  56. copy:
  57. content: "{{ configout.results.results.0.data['volume-config.yaml'] }}"
  58. dest: "{{ mktempout.stdout }}/volume-config.yaml"
  59. when:
  60. - "'data' in configout['results']['results'][0]"
  61. - "'volume-config.yaml' in configout['results']['results'][0]['data']"
  62. - openshift_node_group_name != ""
  63. - openshift_node_local_quota_per_fsgroup is defined
  64. - openshift_node_local_quota_per_fsgroup != ""
  65. run_once: true
  66. - name: "specialize the volume config for {{ openshift_node_group_name }}"
  67. yedit:
  68. content:
  69. src: "{{ mktempout.stdout }}/volume-config.yaml"
  70. key: localQuota.perFSGroup
  71. value: "{{ openshift_node_local_quota_per_fsgroup }}"
  72. register: volume_yeditout
  73. when:
  74. - openshift_node_local_quota_per_fsgroup is defined
  75. - openshift_node_local_quota_per_fsgroup != ""
  76. run_once: true
  77. - name: show the volume_yeditout debug var
  78. debug:
  79. var: volume_yeditout
  80. run_once: true
  81. - name: create node-config.yaml configmap
  82. oc_configmap:
  83. name: "{{ openshift_node_group_name }}"
  84. namespace: "{{ openshift_node_group_namespace }}"
  85. from_file:
  86. node-config.yaml: "{{ mktempout.stdout }}/node-config.yaml"
  87. when:
  88. - openshift_node_local_quota_per_fsgroup is undefined or openshift_node_local_quota_per_fsgroup == ""
  89. run_once: true
  90. - name: create node-config.yaml and volume-config.yaml configmap
  91. oc_configmap:
  92. name: "{{ openshift_node_group_name }}"
  93. namespace: "{{ openshift_node_group_namespace }}"
  94. from_file:
  95. node-config.yaml: "{{ mktempout.stdout }}/node-config.yaml"
  96. volume-config.yaml: "{{ mktempout.stdout }}/volume-config.yaml"
  97. when:
  98. - openshift_node_local_quota_per_fsgroup is defined and openshift_node_local_quota_per_fsgroup != ""
  99. run_once: true
  100. - name: remove templated files
  101. file:
  102. dest: "{{ mktempout.stdout }}/"
  103. state: absent
  104. run_once: true