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
8 anni fa
8 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 --name| grep -E "^{{ 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. {%- if node.get("autostart", True) %}
  59. salt_virt_autostart_{{ cluster_name }}_{{ node_name }}:
  60. module.run:
  61. - name: virt.set_autostart
  62. - vm_: {{ node_name }}.{{ cluster.domain }}
  63. - state: true
  64. - unless: virsh list --autostart --name| grep -E "^{{ node_name }}.{{ cluster.domain }}$"
  65. {%- endif %}
  66. {%- endif %}
  67. {%- endfor %}
  68. {%- endif %}
  69. {%- endfor %}
  70. {%- endif %}