Created
March 14, 2019 15:29
-
-
Save philmadden83/edfa1ed26c7f8a49c88b4cad533b710f to your computer and use it in GitHub Desktop.
Virtualbox role for ansible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Create tmp Download Dir | |
file: | |
path: "{{ ansible_user_dir }}/tmp/virtualbox/{{ virtualbox_version }}" | |
state: directory | |
recurse: yes | |
#- name: Download .dmg | |
# get_url: | |
# url: "https://download.virtualbox.org/virtualbox/{{ virtualbox_version }}/{{ virtualbox_dmg_name }}" | |
# dest: "{{ ansible_user_dir }}/tmp/virtualbox/{{ virtualbox_version }}" | |
- name: Mount the .dmg | |
command: "hdiutil attach {{ ansible_user_dir }}/tmp/virtualbox/{{ virtualbox_version }}/{{ virtualbox_dmg_name }} -nobrowse -mountpoint /Volumes/Virtualbox_{{ virtualbox_version }}" | |
- name: Remove expand path | |
file: | |
path: "{{ ansible_user_dir }}/tmp/virtualbox_exp" | |
state: absent | |
- name: Expand the .pkg file | |
command: "pkgutil --expand-full /Volumes/Virtualbox_{{ virtualbox_version }}/VirtualBox.pkg {{ ansible_user_dir }}/tmp/virtualbox_exp" | |
- name: Create package paths | |
file: | |
path: "{{ item }}" | |
recurse: yes | |
state: directory | |
owner: "{{ virtualbox_user_id }}" | |
group: wheel | |
mode: 0755 | |
become: yes | |
with_items: | |
- "/usr/local/virtualbox/{{ virtualbox_version }}" | |
- "/usr/local/virtualbox/{{ virtualbox_version }}/include" | |
- "/usr/local/virtualbox/{{ virtualbox_version }}/Library" | |
- "/usr/local/virtualbox/{{ virtualbox_version }}/Library/Filesystems" | |
- "/usr/local/virtualbox/{{ virtualbox_version }}/Library/Frameworks" | |
- "/Library/Application Support/VirtualBox" | |
- name: Run preflight steps | |
command: "{{ ansible_user_dir }}/tmp/virtualbox_exp/VirtualBox.pkg/Scripts/preflight" | |
become: yes | |
environment: | |
INSTALLER_TEMP: "{{ ansible_user_dir }}/tmp/virtualbox_exp" | |
#- name: Install the app | |
# copy: | |
# src: "{{ ansible_user_dir }}/tmp/virtualbox_exp/VirtualBox.pkg/Payload/Virtualbox.app" | |
# dest: "{{ virtualbox_install_dir }}" | |
# owner: "{{ ansible_user_id }}" | |
# group: "wheel" | |
# mode: 0755 | |
- name: Install the CLI tools | |
copy: | |
src: "{{ ansible_user_dir }}/tmp/virtualbox_exp/VirtualBoxCLI.pkg/Payload/{{ item }}" | |
dest: "/usr/local/virtualbox/{{ virtualbox_version }}/{{ item }}" | |
with_items: | |
- VBoxAutostart | |
- VBoxBalloonCtrl | |
- VBoxBugReport | |
- VBoxDTrace | |
- VBoxHeadless | |
- VBoxManage | |
- VBoxVRDP | |
- VirtualBox | |
- VirtualBoxVM | |
- vbox-img | |
- vboximg-mount | |
- vboxwebsrv | |
- name: Run FuseCore pre install steps | |
command: "{{ ansible_user_dir }}/tmp/virtualbox_exp/OSXFuseCore.pkg/Scripts/preinstall" | |
become: yes | |
- name: Install FuseCore includes | |
copy: | |
src: "{{ ansible_user_dir }}/tmp/virtualbox_exp/OSXFuseCore.pkg/Payload/usr/local/include/osxfuse" | |
dest: "/usr/local/virtualbox/{{ virtualbox_version }}/include" | |
- name: Install FuseCore Filesystem | |
copy: | |
src: "{{ ansible_user_dir }}/tmp/virtualbox_exp/OSXFuseCore.pkg/Payload/Library/Filesystems/osxfuse.fs" | |
dest: "/usr/local/virtualbox/{{ virtualbox_version }}/Library/Filesystems" | |
- name: Install FuseCore Framework | |
copy: | |
src: "{{ ansible_user_dir }}/tmp/virtualbox_exp/OSXFuseCore.pkg/Payload/Library/Frameworks/OSXFUSE.framework" | |
dest: "/usr/local/virtualbox/{{ virtualbox_version }}/Library/Frameworks" | |
- name: Install Application Support | |
copy: | |
src: "{{ ansible_user_dir }}/tmp/virtualbox_exp/VBoxKEXTs.pkg/Payload/{{ item }}" | |
dest: "/usr/local/virtualbox/{{ virtualbox_version }}" | |
become: yes | |
with_items: | |
- LaunchDaemons | |
- VBoxDrv.kext | |
- VBoxNetAdp.kext | |
- VBoxNetFlt.kext | |
- VBoxUSB.kext | |
- name: Link Application Support files | |
file: | |
src: "/usr/local/virtualbox/{{ virtualbox_version }}/{{ item }}" | |
dest: "/Library/Application Support/VirtualBox" | |
with_items: | |
- LaunchDaemons | |
- VBoxDrv.kext | |
- VBoxNetAdp.kext | |
- VBoxNetFlt.kext | |
- VBoxUSB.kext | |
- name: Link the CLI tools | |
file: | |
src: "/usr/local/virtualbox/{{ virtualbox_version }}/{{ item }}" | |
dest: "/usr/local/bin/{{ item }}" | |
state: link | |
with_items: "{{ virtualbox_cli_tools }}" | |
- name: Link the OSX FuseCore includes | |
file: | |
src: "/usr/local/virtualbox/{{ virtualbox_version }}/include/osxfuse/fuse.h" | |
dest: "/usr/local/include/fuse.h" | |
state: link | |
- name: Link the OSX FuseCore Filesystem | |
file: | |
src: "/usr/local/virtualbox/{{ virtualbox_version }}/Library/Filesystems/osxfuse.fs" | |
dest: "/Library/Filesystems/osxfuse.fs" | |
state: link | |
become: yes | |
- name: Link the OSX FuseCore Framework | |
file: | |
src: "/usr/local/virtualbox/{{ virtualbox_version }}/Library/Frameworks/OSXFUSE.framework" | |
dest: "/Library/Frameworks/OSXFUSE.framework" | |
state: link | |
become: yes | |
- name: Run FuseCore post install steps | |
command: "{{ ansible_user_dir }}/tmp/virtualbox_exp/OSXFuseCore.pkg/Scripts/postinstall" | |
become: yes | |
- name: Run post flight steps | |
command: "{{ ansible_user_dir }}/tmp/virtualbox_exp/VirtualBox.pkg/Scripts/postflight" | |
become: yes | |
environment: | |
INSTALLER_TEMP: "{{ ansible_user_dir }}/tmp/virtualbox_exp" | |
- name: Run VBoxKEXTs post flight steps | |
command: "{{ ansible_user_dir }}/tmp/virtualbox_exp/VBoxKEXTs.pkg/Scripts/postflight" | |
become: yes | |
- command: "hdiutil detach -force /Volumes/Virtualbox_{{ virtualbox_version }}" | |
ignore_errors: yes | |
#- name: Cleanup | |
# file: | |
# path: "{{ ansible_user_dir }}/tmp/virtualbox" | |
# state: absent | |
- name: Cleanup Expanded file | |
file: | |
path: "{{ ansible_user_dir }}/tmp/virtualbox_exp" | |
state: absent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment