New version of salt-formula from Saltstack
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

94 lines
2.3KB

  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. ##Posibility to disable rng device globally for old libvirt version
  18. {%- if cluster.rng is defined %}
  19. {%- set rng = cluster.rng %}
  20. {%- endif %}
  21. {%- for node_name, node in cluster.node.iteritems() %}
  22. {%- if node.name is defined %}
  23. {%- set node_name = node.name %}
  24. {%- endif %}
  25. {%- if node.provider == grains.id %}
  26. {%- set size = control.size.get(node.size) %}
  27. salt_control_virt_{{ cluster_name }}_{{ node_name }}:
  28. module.run:
  29. - name: virtng.init
  30. - m_name: {{ node_name }}.{{ cluster.domain }}
  31. - cpu: {{ size.cpu }}
  32. - mem: {{ size.ram }}
  33. - image: {{ node.image }}
  34. - start: True
  35. - disk: {{ size.disk_profile }}
  36. - nic: {{ size.net_profile }}
  37. {%- if node.rng is defined %}
  38. - rng: {{ node.rng }}
  39. {%- elif rng is defined %}
  40. - rng: {{ rng }}
  41. {%- endif %}
  42. - kwargs:
  43. seed: True
  44. serial_type: pty
  45. console: True
  46. {%- if node.img_dest is defined %}
  47. img_dest: {{ node.img_dest }}
  48. {%- endif %}
  49. {%- if node.mac is defined %}
  50. {%- for mac_name, mac in node.mac.items() %}
  51. {{ mac_name }}_mac: {{ mac }}
  52. {%- endfor %}
  53. {%- endif %}
  54. - unless: virsh list --all --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
  55. #salt_control_seed_{{ cluster_name }}_{{ node_name }}:
  56. # module.run:
  57. # - name: seed.apply
  58. # - path: /srv/salt-images/{{ node_name }}.{{ cluster.domain }}/system.qcow2
  59. # - id_: {{ node_name }}.{{ cluster.domain }}
  60. # - unless: virsh list | grep {{ node_name }}.{{ cluster.domain }}
  61. {%- if node.get("autostart", True) %}
  62. salt_virt_autostart_{{ cluster_name }}_{{ node_name }}:
  63. module.run:
  64. - name: virt.set_autostart
  65. - vm_: {{ node_name }}.{{ cluster.domain }}
  66. - state: true
  67. - unless: virsh list --autostart --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
  68. {%- endif %}
  69. {%- endif %}
  70. {%- endfor %}
  71. {%- endif %}
  72. {%- endfor %}
  73. {%- endif %}