Files
vms/ansible/roles/virtualbox/tasks/main.yml
T

57 lines
1.6 KiB
YAML
Raw Normal View History

2022-06-08 01:39:37 -05:00
- 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
2022-05-02 22:03:37 -05:00
become: true
2022-05-05 08:17:48 -05:00
ansible.builtin.package:
2022-05-02 22:03:37 -05:00
name: "{{ virtualbox_packages }}"
state: present
2022-06-08 01:39:37 -05:00
update_cache: true
register: _pkg_install
retries: 3
until: _pkg_install is success
2022-05-02 22:03:37 -05:00
2022-06-08 01:39:37 -05:00
- name: Start services
2022-05-02 22:03:37 -05:00
become: true
2022-05-05 08:17:48 -05:00
ansible.builtin.service:
2022-05-02 22:03:37 -05:00
name: "{{ item }}"
state: started
enabled: true
loop: "{{ virtualbox_services }}"
2022-06-08 02:27:48 -05:00
- name: Run commands to install from ISO
when: virtualbox_from_iso
2022-06-19 15:15:35 -05:00
become: true
2022-06-08 01:39:37 -05:00
block:
2022-06-19 15:15:35 -05:00
- 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
2022-06-08 01:39:37 -05:00
changed_when: false
failed_when: _cmd.rc not in [0, 2]
register: _cmd
2022-06-19 15:15:35 -05:00
- name: Unmount ISO file
ansible.posix.mount:
path: /mnt
state: absent
2022-05-02 22:03:37 -05:00
2022-06-08 01:39:37 -05:00
- name: Remove packages
become: true
ansible.builtin.package:
name: "{{ virtualbox_remove_packages | default([]) }}"
2022-05-02 22:03:37 -05:00
state: absent