New version of salt-formula from Saltstack
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

88 lines
2.1KB

  1. {% from "salt/map.jinja" import control with context %}
  2. {%- if control.enabled and control.virt_enabled is defined %}
  3. include:
  4. - salt.minion
  5. salt_control_virt_packages:
  6. pkg.installed:
  7. - names: {{ control.virt_pkgs }}
  8. {% if grains.oscodename == 'trusty' %}
  9. {#- This tool is not available in newer releases #}
  10. update-guestfs-appliance:
  11. cmd.wait:
  12. - watch:
  13. - pkg: salt_control_virt_packages
  14. {%- endif %}
  15. {%- for cluster_name, cluster in control.cluster.iteritems() %}
  16. {%- if cluster.engine == "virt" %}
  17. {%- for node_name, node in cluster.node.iteritems() %}
  18. {%- if node.name is defined %}
  19. {%- set node_name = node.name %}
  20. {%- endif %}
  21. {%- if node.provider == grains.id %}
  22. {%- set size = control.size.get(node.size) %}
  23. salt_control_virt_{{ cluster_name }}_{{ node_name }}:
  24. module.run:
  25. - name: virtng.init
  26. - m_name: {{ node_name }}.{{ cluster.domain }}
  27. - cpu: {{ size.cpu }}
  28. - mem: {{ size.ram }}
  29. - image: {{ node.image }}
  30. - start: True
  31. - disk: {{ size.disk_profile }}
  32. - nic: {{ size.net_profile }}
  33. {%- if node.rng is defined %}
  34. - rng: {{ node.rng }}
  35. {%- endif %}
  36. - kwargs:
  37. seed: True
  38. serial_type: pty
  39. console: True
  40. {%- if node.img_dest is defined %}
  41. img_dest: {{ node.img_dest }}
  42. {%- endif %}
  43. {%- if node.mac is defined %}
  44. {%- for mac_name, mac in node.mac.items() %}
  45. {{ mac_name }}_mac: {{ mac }}
  46. {%- endfor %}
  47. {%- endif %}
  48. - unless: virsh list --all --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
  49. #salt_control_seed_{{ cluster_name }}_{{ node_name }}:
  50. # module.run:
  51. # - name: seed.apply
  52. # - path: /srv/salt-images/{{ node_name }}.{{ cluster.domain }}/system.qcow2
  53. # - id_: {{ node_name }}.{{ cluster.domain }}
  54. # - unless: virsh list | grep {{ node_name }}.{{ cluster.domain }}
  55. {%- if node.get("autostart", True) %}
  56. salt_virt_autostart_{{ cluster_name }}_{{ node_name }}:
  57. module.run:
  58. - name: virt.set_autostart
  59. - vm_: {{ node_name }}.{{ cluster.domain }}
  60. - state: true
  61. - unless: virsh list --autostart --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
  62. {%- endif %}
  63. {%- endif %}
  64. {%- endfor %}
  65. {%- endif %}
  66. {%- endfor %}
  67. {%- endif %}