Skip to content

RomanShestakov/vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README for Vagrant dev linux box

Description

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.

Intall Docker Desktop

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

Install Ansible

$ brew install ansible

Install Packer

$ brew install packer

Install Vagrant

https://www.vagrantup.com/downloads.html

Build with packer Docker image

The build might take few hours as ansible roles will build gcc, llvm, etc from sources

packer build provision/centos7.json

Push Docker image to dockerHub

docker login -u "rshestakov" -p <password> docker.io
docker push rshestakov/vm:6.

Build vagrant image based on Docker image

vagrant up

SSH to the vagrant VM

vagrant ssh

SSH to the vagrant VM

vagrant ssh-config
ssh -o "StrictHostKeyChecking=no" -i .vagrant/machines/default/docker/private_key vagrant@localhost -p 2222

Some things to notice

** 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published