set_defaults_from_current.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. ---
  2. ## We are pulling default values from configmaps if they exist already
  3. ## Using conditional_set_fact allows us to set the value of a variable based on
  4. ## the value of another one, if it is already defined. Else we don't set the
  5. ## left hand side (it stays undefined as well).
  6. ## conditional_set_fact allows us to specify a fact source, so first we try to
  7. ## set variables in the logging-elasticsearch & logging-elasticsearch-ops configmaps
  8. ## afterwards we set the value of the variable based on the value in the inventory
  9. ## but fall back to using the value from a configmap as a default. If neither is set
  10. ## then the variable remains undefined and the role default will be used.
  11. - conditional_set_fact:
  12. facts: "{{ openshift_logging_facts['elasticsearch']['configmaps']['logging-elasticsearch']['elasticsearch.yml'] | flatten_dict }}"
  13. vars:
  14. __openshift_logging_es_number_of_shards: index.number_of_shards
  15. __openshift_logging_es_number_of_replicas: index.number_of_replicas
  16. when: openshift_logging_facts['elasticsearch']['configmaps']['logging-elasticsearch'] is defined
  17. - conditional_set_fact:
  18. facts: "{{ openshift_logging_facts['elasticsearch_ops']['configmaps']['logging-elasticsearch-ops']['elasticsearch.yml'] | flatten_dict }}"
  19. vars:
  20. __openshift_logging_es_ops_number_of_shards: index.number_of_shards
  21. __openshift_logging_es_ops_number_of_replicas: index.number_of_replicas
  22. when: openshift_logging_facts['elasticsearch_ops']['configmaps']['logging-elasticsearch-ops'] is defined
  23. - conditional_set_fact:
  24. facts: "{{ hostvars[inventory_hostname] }}"
  25. vars:
  26. openshift_logging_es_number_of_shards: openshift_logging_es_number_of_shards | __openshift_logging_es_number_of_shards
  27. openshift_logging_es_number_of_replicas: openshift_logging_es_number_of_replicas | __openshift_logging_es_number_of_replicas
  28. openshift_logging_es_ops_number_of_shards: openshift_logging_es_ops_number_of_shards | __openshift_logging_es_ops_number_of_shards
  29. openshift_logging_es_ops_number_of_replicas: openshift_logging_es_ops_number_of_replicas | __openshift_logging_es_ops_number_of_replicas