A Vagrant VM using Docker provider and provisioned with ansible. This VM is used for development purposes and uses Centos7. Ansible roles are used to build gcc, llvm and some other packages from sources. I want to be able to use the same environment using different CPU archetectures - e.g. x86 or Apple M1 chip (aarch64) so the best way to archive this is to use Docker as VirtualBox hypervisor doesn’t work for M1.
As the vagrant need a provider - install Docker on the host computer first.
I tested with Docker Desktop 4.4.2 https://docs.docker.com/desktop/mac/release-notes/#docker-desktop-442
$ brew install ansible
$ brew install packer
https://www.vagrantup.com/downloads.html
The build might take few hours as ansible roles will build gcc, llvm, etc from sources
packer build provision/centos7.json
docker login -u "rshestakov" -p <password> docker.io docker push rshestakov/vm:6.
vagrant up
vagrant ssh
vagrant ssh-config ssh -o "StrictHostKeyChecking=no" -i .vagrant/machines/default/docker/private_key vagrant@localhost -p 2222
** How external ansible roles are applied As part of the VM provision Vagrant will execute ansible role to apply certain configurations. This is triggered by the following line in the Vagrantfile
ansible.playbook = 'provision/ansible/playbooks/base.yml'
Vagrant also executes the following snippet which run role_update.sh script which pulls from hithub all the required by the base.yml ansible roles.
system(" if [ #{ARGV[0]} = 'up' ]; then echo 'You are doing vagrant up and can execute your script' ./provision/scripts/role_update.sh fi ")
The list of the roles is defined in the vm/provision/ansible/playbooks/roles/roles_requirements.yml