libvirt.sls 2.07 KB
Newer Older
1 2 3 4 5
augeas_dependency:
  pkg.installed:
    - pkgs:
      - python-augeas

Bach Dániel committed
6
libvirtconf:
7 8
  augeas.change:
    - context: /files/etc/libvirt/libvirtd.conf
Bach Dániel committed
9
    - changes:
10 11 12
      - set listen_tcp 1
      - set listen_tls 0
      - set auth_tcp "none"
Bach Dániel committed
13 14 15 16 17

/etc/default/libvirt-bin:
  file.append:
    - text: libvirtd_opts="-d -l"

Bach Dániel committed
18 19 20
{% if grains['os_family'] == 'RedHat' %}
libvirtd:
{% else %}
Bach Dániel committed
21
libvirt-bin:
Bach Dániel committed
22
{% endif %}
Bach Dániel committed
23 24 25 26 27 28
  service:
    - running
    - watch:
      - file: /etc/default/libvirt-bin
      - augeas: libvirtconf

Bach Dániel committed
29 30 31 32 33
{% if grains['os_family'] == 'RedHat' %}
/usr/bin/kvm:
  file.symlink:
    - target: /usr/libexec/qemu-kvm

Bach Dániel committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/etc/polkit-1/rules.d/10.virt.rules:
  file.managed:
    - source: salt://vmdriver/files/10.virt.rules
    - template: jinja
    - mode: 644

polkit:
  service:
    - running
    - watch:
      - file: /etc/polkit-1/rules.d/10.virt.rules

/root/vmdriver.te:
  file.managed:
    - source: salt://vmdriver/files/vmdriver.te
    - template: jinja
    - mode: 644

selinux_pkgs:
  pkg.installed:
    - pkgs:
      - policycoreutils
      - policycoreutils-python

vmdriver_semodule:
  cmd.run:
    - cwd: /root
    - user: root
    - name: checkmodule -M -m -o vmdriver.mod vmdriver.te; semodule_package -o vmdriver.pp -m vmdriver.mod; semodule -i vmdriver.pp
    - unless: semodule -l |grep -qs ^vmdriver
    - require:
      - file: /root/vmdriver.te
      - pkg: selinux_pkgs

Bach Dániel committed
68 69
{% else %}

Bach Dániel committed
70 71 72 73 74 75 76 77 78 79 80
/etc/apparmor.d/libvirt/TEMPLATE:
  file.managed:
    - source: salt://vmdriver/files/apparmor-libvirt
    - template: jinja
    - mode: 644

/etc/apparmor.d/usr.lib.libvirt.virt-aa-helper:
  file.managed:
    - source: salt://vmdriver/files/usr.lib.libvirt.virt-aa-helper
    - template: jinja
    - mode: 644
Bach Dániel committed
81 82 83 84 85 86 87 88

apparmor:
  service:
    - reload: true
    - running
    - watch:
      - file: /etc/apparmor.d/libvirt/TEMPLATE
      - file: /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper
Bach Dániel committed
89
{% endif %}
Bach Dániel committed
90 91 92 93

/var/lib/libvirt/serial:
  file.directory:
    - makedirs: True
Bach Dániel committed
94 95 96
    {% if grains['os_family'] == 'RedHat' %}
    - user: qemu
    {% else %}
Bach Dániel committed
97
    - user: libvirt-qemu
Bach Dániel committed
98
    {% endif %}
Bach Dániel committed
99 100
    - group: kvm
    - mode: 755