--- - hosts: localhost connection: local become: true tasks: - name: Add an Apt signing key, uses whichever key is at the URL ansible.builtin.apt_key: url: https://apt.releases.hashicorp.com/gpg state: present - name: Add an Apt signing key, uses whichever key is at the URL ansible.builtin.apt_key: url: https://www.virtualbox.org/download/oracle_vbox_2016.asc state: present - name: Add an Apt signing key, uses whichever key is at the URL ansible.builtin.apt_key: url: https://www.virtualbox.org/download/oracle_vbox.asc state: present - name: Add specified repository into sources list using specified filename ansible.builtin.apt_repository: repo: deb [arch=amd64] https://apt.releases.hashicorp.com {{ ansible_distribution_release | lower }} main state: present filename: vagrant - name: Add specified repository into sources list using specified filename ansible.builtin.apt_repository: repo: deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian {{ ansible_distribution_release | lower }} contrib state: present filename: vagrant - name: install packages package: name: - vagrant - virtualbox - name: Check if extension pack is already installed shell: "VBoxManage list extpacks" register: extpack_list - name: Output installed extpacks debug: var: extpack_list.stdout - name: Download VirtualBox extension pack get_url: url: "https://download.virtualbox.org/virtualbox/6.1.26/Oracle_VM_VirtualBox_Extension_Pack-6.1.26.vbox-extpack" dest: /tmp/ force: yes register: download_result #when: 'extpack_list.stdout == "Extension Packs: 1*"' - name: Output downloaded VirtualBox extension pack file name debug: var: download_result.dest verbosity: 1 - name: Install VirtualBox extension pack shell: "echo 'y' | VBoxManage extpack install --replace {{ download_result.dest }} --accept-license=33d7284dc4a0ece381196fda3cfe2ed0e1e8e7ed7f27b9a9ebc4ee22e24bd23c" #when: 'extpack_list.stdout == "Extension Packs: 0"'