Files
vms/ansible/roles/virtualbox/tasks/main.yml
T
Greg HellingsandGitHub 214b1974ca Fix virtualbox tools install (#9)
Ubuntu 22.04 has the tools available and does not need to install from
ISO. This was hanging, though no output seemed to indicate why. So we're
avoiding the ISO altogether and going with the Ubuntu packages
2022-06-19 15:15:35 -05:00

57 lines
1.6 KiB
YAML

- name: Load version information
ansible.builtin.include_vars: "{{ item }}"
loop:
- "{{ role_path }}/vars/{{ ansible_facts['os_family'] }}.yml"
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}.yml"
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
- "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml"
when: item is file
- name: Install build deps for virtualbox addons
become: true
ansible.builtin.package:
name: "{{ virtualbox_packages }}"
state: present
update_cache: true
register: _pkg_install
retries: 3
until: _pkg_install is success
- name: Start services
become: true
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop: "{{ virtualbox_services }}"
- name: Run commands to install from ISO
when: virtualbox_from_iso
become: true
block:
- name: Mount ISO file
ansible.posix.mount:
fstype: auto
path: /mnt
src: "{{ virtualbox_iso_location }}"
state: mounted
boot: false
opts: loop
- name: Install additions
ansible.builtin.command: /mnt/VBoxLinuxAdditions.run --nox11 2>&1 > /root/vbox_addon_install.log
changed_when: false
failed_when: _cmd.rc not in [0, 2]
register: _cmd
- name: Unmount ISO file
ansible.posix.mount:
path: /mnt
state: absent
- name: Remove packages
become: true
ansible.builtin.package:
name: "{{ virtualbox_remove_packages | default([]) }}"
state: absent