184 lines
4.3 KiB
YAML
184 lines
4.3 KiB
YAML
---
|
|
- name: install libvirt packages
|
|
apt:
|
|
name:
|
|
- libvirt-daemon-system
|
|
- virt-manager
|
|
state: latest
|
|
autoremove: true
|
|
|
|
#- name: allow all users to use VMs
|
|
# lineinfile:
|
|
# dest: /etc/libvirt/libvirtd.conf
|
|
# line: 'auth_unix_rw = "none"'
|
|
# insertafter: '#auth_unix_rw = "polkit"'
|
|
# notify: reload libvirtd
|
|
|
|
- name: Configure pam_mount for VMs
|
|
blockinfile:
|
|
dest: /etc/security/pam_mount.conf.xml
|
|
marker: "<!-- {mark} ANSIBLE MANAGED BLOCK (bind mounts for VMs) -->"
|
|
block: |
|
|
<!-- bind mounts for the VMs, setting gid here does not work -->
|
|
<volume
|
|
path="~"
|
|
mountpoint="/lmn/media/%(USER)/home"
|
|
options="bind"
|
|
><not><or><user>root</user><user>ansible</user><user>Debian-gdm</user><user>sddm</user><user>virti</user></or></not>
|
|
</volume>
|
|
<volume
|
|
path="/srv/samba/schools/default-school/share"
|
|
mountpoint="/lmn/media/%(USER)/share"
|
|
options="bind"
|
|
><not><or><user>root</user><user>ansible</user><user>Debian-gdm</user><user>sddm</user><user>virti</user></or></not>
|
|
</volume>
|
|
insertafter: "<!-- END ANSIBLE MANAGED BLOCK .* -->"
|
|
|
|
- name: autostart default network for VMs
|
|
file:
|
|
src: /etc/libvirt/qemu/networks/default.xml
|
|
dest: /etc/libvirt/qemu/networks/autostart/default.xml
|
|
state: link
|
|
|
|
- name: create system-user syncing VM-files and others
|
|
ansible.builtin.user:
|
|
name: lmnsynci
|
|
comment: lmn sync user
|
|
system: true
|
|
create_home: false
|
|
|
|
- name: create vm directory
|
|
file:
|
|
path: /lmn/vm
|
|
state: directory
|
|
owner: lmnsynci
|
|
group: lmnsynci
|
|
mode: 0755
|
|
|
|
- name: install squid
|
|
apt:
|
|
name:
|
|
- squid
|
|
state: latest
|
|
autoremove: true
|
|
|
|
- name: disable squid
|
|
systemd:
|
|
name: squid
|
|
enabled: false
|
|
state: stopped
|
|
|
|
- name: deploy squid user mode configuration
|
|
template:
|
|
src: squid-usermode.conf.j2
|
|
dest: /etc/squid/squid-usermode.conf
|
|
mode: '0644'
|
|
|
|
- name: deploy sudo configurations
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: "/etc/sudoers.d/90-{{ item }}"
|
|
owner: root
|
|
group: root
|
|
mode: '0700'
|
|
loop:
|
|
- lmn-mounthome
|
|
- lmn-sync-vm
|
|
- lmn-upload-vm
|
|
- lmn-link-images
|
|
- lmn-startvirtiofsd
|
|
|
|
- name: deploy vmimages scripts
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: /usr/local/bin/
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
loop:
|
|
- mounthome.sh
|
|
- create-vm.sh
|
|
- rebase-vm.sh
|
|
- create-clone.sh
|
|
- run-vm.sh
|
|
- upload-vm.sh
|
|
- sync-vm.sh
|
|
- link-images.sh
|
|
- start-virtiofsd.sh
|
|
- linbo-torrenthelper.sh
|
|
- vmimage-torrent
|
|
|
|
- name: Deploy linbo-torrent defaults
|
|
copy:
|
|
src: linbo-torrent
|
|
dest: /etc/default/
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
|
|
- name: Deploy vmimage-torrent.service
|
|
copy:
|
|
src: vmimage-torrent.service
|
|
dest: /etc/systemd/system/
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
notify: "enable vmimage-torrent.service"
|
|
|
|
- name: Deploy bridge.conf needed for qemu session mode
|
|
lineinfile:
|
|
path: /etc/qemu/bridge.conf
|
|
line: 'allow virbr0'
|
|
create: True
|
|
mode: '0655'
|
|
|
|
- name: Deploy rsync.secret
|
|
lineinfile:
|
|
path: /etc/rsync.secret
|
|
line: "{{ rsyncsecret }}"
|
|
create: True
|
|
mode: '0600'
|
|
|
|
- name: Allow users to attach to bridge
|
|
file:
|
|
path: /usr/lib/qemu/qemu-bridge-helper
|
|
mode: '4755'
|
|
|
|
- name: Deploy http proxy config
|
|
copy:
|
|
src: lmn-proxy.sh
|
|
dest: /etc/profile.d/
|
|
mode: '0644'
|
|
|
|
- name: Create directory for local .desktop-Files
|
|
ansible.builtin.file:
|
|
path: "{ item }"
|
|
state: directory
|
|
mode: '0755'
|
|
loop:
|
|
- /usr/local/share/applications
|
|
- /usr/local/share/desktop-directories
|
|
notify: Run update-desktop-database
|
|
|
|
- name: set owner lmnsynci for menu entry directory
|
|
file:
|
|
path: /usr/local/share/applications
|
|
state: directory
|
|
owner: lmnsynci
|
|
|
|
- name: Copy fvs.directory
|
|
ansible.builtin.copy:
|
|
src: fvs.directory
|
|
dest: /usr/local/share/desktop-directories/
|
|
notify: Run update-desktop-database
|
|
|
|
- name: Copy fvs.menu
|
|
ansible.builtin.copy:
|
|
src: fvs.menu
|
|
dest: /etc/xdg/menus/applications-merged/
|
|
notify: Run update-desktop-database
|
|
|
|
- name: sync .torrent, .xml and .desktop files and run update-desktop-database
|
|
command: sudo -u lmnsynci /usr/local/bin/sync-vm.sh -t
|
|
register: result
|
|
changed_when: result.stdout | length > 0
|