New version of salt-formula from Saltstack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 anni fa
8 anni fa
8 anni fa
8 anni fa
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. - kwargs:
  34. seed: True
  35. serial_type: pty
  36. console: True
  37. {%- if node.img_dest is defined %}
  38. img_dest: {{ node.img_dest }}
  39. {%- endif %}
  40. - unless: virsh list --all --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
  41. #salt_control_seed_{{ cluster_name }}_{{ node_name }}:
  42. # module.run:
  43. # - name: seed.apply
  44. # - path: /srv/salt-images/{{ node_name }}.{{ cluster.domain }}/system.qcow2
  45. # - id_: {{ node_name }}.{{ cluster.domain }}
  46. # - unless: virsh list | grep {{ node_name }}.{{ cluster.domain }}
  47. {%- if node.get("autostart", True) %}
  48. salt_virt_autostart_{{ cluster_name }}_{{ node_name }}:
  49. module.run:
  50. - name: virt.set_autostart
  51. - vm_: {{ node_name }}.{{ cluster.domain }}
  52. - state: true
  53. - unless: virsh list --autostart --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
  54. {%- endif %}
  55. {%- endif %}
  56. {%- endfor %}
  57. {%- endif %}
  58. {%- endfor %}
  59. {%- endif %}