New version of salt-formula from Saltstack
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

82 行
1.8KB

  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. {%- if not grains.get('noservices', False) %}
  29. - watch_in:
  30. - service: salt_minion_service
  31. {%- endif %}
  32. {%- for cluster_name, cluster in control.cluster.iteritems() %}
  33. {%- if cluster.engine == "virt" %}
  34. {%- for node_name, node in cluster.node.iteritems() %}
  35. {%- if node.provider == grains.id %}
  36. {%- set size = control.size.get(node.size) %}
  37. salt_control_virt_{{ cluster_name }}_{{ node_name }}:
  38. module.run:
  39. - name: virtng.init
  40. - m_name: {{ node_name }}.{{ cluster.domain }}
  41. - cpu: {{ size.cpu }}
  42. - mem: {{ size.ram }}
  43. - image: {{ node.image }}
  44. - start: True
  45. - disk: {{ size.disk_profile }}
  46. - nic: {{ size.net_profile }}
  47. - kwargs:
  48. seed: True
  49. serial_type: pty
  50. console: True
  51. - unless: virsh list --all | grep {{ node_name }}.{{ cluster.domain }}
  52. #salt_control_seed_{{ cluster_name }}_{{ node_name }}:
  53. # module.run:
  54. # - name: seed.apply
  55. # - path: /srv/salt-images/{{ node_name }}.{{ cluster.domain }}/system.qcow2
  56. # - id_: {{ node_name }}.{{ cluster.domain }}
  57. # - unless: virsh list | grep {{ node_name }}.{{ cluster.domain }}
  58. {%- endif %}
  59. {%- endfor %}
  60. {%- endif %}
  61. {%- endfor %}
  62. {%- endif %}