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.

virt.sls 2.5KB

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