set_calculation_needed.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. - debug:
  2. var: dom
  3. - name: Prüfen, wo Variablen nachberechnet werden müssen
  4. set_fact:
  5. domaenenliste: "{{domaenenliste | combine( {dom: {'calculation_needed' : 'true'}}, recursive=True)}}"
  6. when: "(domaenenliste[dom].server_id is not defined) or (domaenenliste[dom].dhcp_start is not defined) or (domaenenliste[dom].dhcp_ende is not defined)"
  7. - name: Partner setzen
  8. when: "domaenenliste[dom].calculation_needed is defined and domaenenliste[dom].calculation_needed == 'true'"
  9. with_items: "{{ groups['supernodes'] }}"
  10. loop_control:
  11. loop_var: gates
  12. include: find_partner.yml supernode={{gates}}
  13. - name: server_id auf 2 setzen, falls andere vm_id größer
  14. when: "domaenenliste[dom].calculation_needed is defined and domaenenliste[dom].calculation_needed == 'true' and hostvars[domaenenliste[dom].partner].vm_id > vm_id"
  15. set_fact:
  16. domaenenliste: "{{domaenenliste | combine( {dom: {'server_id' : 2}}, recursive=True)}}"
  17. - name: server_id auf 3 setzen, falls andere vm_id kleiner
  18. when: "domaenenliste[dom].calculation_needed is defined and domaenenliste[dom].calculation_needed == 'true' and hostvars[domaenenliste[dom].partner].vm_id < vm_id"
  19. set_fact:
  20. domaenenliste: "{{domaenenliste | combine( {dom: {'server_id' : 3}}, recursive=True)}}"
  21. - name: Unterer DHCP-Bereich
  22. when: "domaenenliste[dom].calculation_needed is defined and domaenenliste[dom].calculation_needed == 'true' and domaenenliste[dom].server_id == 2"
  23. set_fact:
  24. domaenenliste: "{{domaenenliste | combine( {dom: {'dhcp_start' : '10.' + dom | int | string + '.64.0', 'dhcp_ende' : '10.' + dom | int | string + '.127.255' }}, recursive=True)}}"
  25. - name: Oberer DHCP-Bereich
  26. when: "domaenenliste[dom].calculation_needed is defined and domaenenliste[dom].calculation_needed == 'true' and domaenenliste[dom].server_id == 3"
  27. set_fact:
  28. domaenenliste: "{{domaenenliste | combine( {dom: {'dhcp_start' : '10.' + dom | int | string + '.128.0', 'dhcp_ende' : '10.' + dom | int | string + '.191.255' }}, recursive=True)}}"