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.

80 lines
1.7KB

  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. update-guestfs-appliance:
  9. cmd.wait:
  10. - watch:
  11. - pkg: salt_control_virt_packages
  12. {#
  13. {%- for package in control.virt_pips %}
  14. {{ package }}:
  15. pip.installed:
  16. - require:
  17. - pkg: salt_control_virt_packages
  18. {%- endfor %}
  19. #}
  20. /etc/salt/minion.d/_virt.conf:
  21. file.managed:
  22. - source: salt://salt/files/_virt.conf
  23. - user: root
  24. - group: root
  25. - template: jinja
  26. - require:
  27. - pkg: salt_control_virt_packages
  28. - watch_in:
  29. - service: salt_minion_service
  30. {%- for cluster_name, cluster in control.cluster.iteritems() %}
  31. {%- if cluster.engine == "virt" %}
  32. {%- for node_name, node in cluster.node.iteritems() %}
  33. {%- if node.provider == grains.id %}
  34. {%- set size = control.size.get(node.size) %}
  35. salt_control_virt_{{ cluster_name }}_{{ node_name }}:
  36. module.run:
  37. - name: virtng.init
  38. - m_name: {{ node_name }}.{{ cluster.domain }}
  39. - cpu: {{ size.cpu }}
  40. - mem: {{ size.ram }}
  41. - image: {{ node.image }}
  42. - start: True
  43. - disk: {{ size.disk_profile }}
  44. - nic: {{ size.net_profile }}
  45. - kwargs:
  46. seed: True
  47. serial_type: pty
  48. console: True
  49. - unless: virsh list --all | grep {{ node_name }}.{{ cluster.domain }}
  50. #salt_control_seed_{{ cluster_name }}_{{ node_name }}:
  51. # module.run:
  52. # - name: seed.apply
  53. # - path: /srv/salt-images/{{ node_name }}.{{ cluster.domain }}/system.qcow2
  54. # - id_: {{ node_name }}.{{ cluster.domain }}
  55. # - unless: virsh list | grep {{ node_name }}.{{ cluster.domain }}
  56. {%- endif %}
  57. {%- endfor %}
  58. {%- endif %}
  59. {%- endfor %}
  60. {%- endif %}